1. Class A (extends JFrame) displays a textfield and a "submit" button

2. user populates the textfield and when "Submit" button is clicked, text from textfield is retrieved and passed to class B (through B's Constructor new B(obtainedTextFromtextField in class A) )

3. class B also displays a textfield and a "submit" button. The text obtained from class A, is then set in the textfield of class B.

4. now the user populates the textfield in class B. Now, when the submit button of class B is clicked how can I pass the text obtained from textfield (in class B) to class A?

5. I cannot pass it through Class A's constructor because it is already initialized. If I attempt to call new A(obtainedTextFromtextField in class B) it will create a new instance for class A (i.e. a new frame with textfield and "submit" button will be popped up)

Need Urgent help....


12 Years
Discussion Span
Last Post by masijade

This doesn't seem to be very good design, but you could define a public
method in A for setting whatever field should be set with the data then let A pass a reference to itself when calling B's constructor. Then B can call aRef.method to pass the data.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.