| Author |
Calling JFrame B from JFrame A
|
vinaya kumar
Ranch Hand
Joined: Jan 20, 2002
Posts: 70
|
|
Hello All, I have two Classes A and B both extends JFrame. From A i will to invoke B after disabling A {A.setenabled(false);} Now, When i Close B, I want the 1) parent Frame (A)to be invoked back. 2) want to call a function in A(parent Frame)from within B ,before i go back to parent Frame A. One Solution(don't know whether this is good ) is to register instance of A in B and use that object throughout in B. Is there a better Solution ??? what is the modal dialog funda!! Can i use it here!! Any clues!! Thanks and Regards vinaya Class A Extends JFrame { A() { } public void x() { } public void y() { } } Class B extends JFrame { }
|
 |
Vinod Venugopal
Ranch Hand
Joined: Dec 06, 2000
Posts: 148
|
|
Hi, What you can do is , in A class when u open B instance dialog/frame, call A.hide(); do operation in B frame & when u close B, call A.setVisible(true); The modal funda is you can make a dialog prevent user from clicking any background application, so the user is blocked from invoking another instance of the same dialog which is a very good feature. This is present only for JDialogs. I dunno ur exact requirement so cant comment , otherwise I would have used A as a frame & B as a JDialog. Vinod
|
- Vinod<br />-------<br />SCJP2
|
 |
vinaya kumar
Ranch Hand
Joined: Jan 20, 2002
Posts: 70
|
|
Thanks VenuGopal i have list chooser ( two lists and buttons) a text field, a combobox,two text area Can i fit all these in JDialog... hmm! i think i can!! :roll: Will this be a proper methodology... further! i want to invoke the parent Class function, how will i do this!!! i.e public class A extends JFrame { somefunction() { //Call to B b.show(); } public void x() } public class B Extends JDialog { B() { .... .... setModal(true); .... } }
|
 |
vinaya kumar
Ranch Hand
Joined: Jan 20, 2002
Posts: 70
|
|
Thanks VenuGopal i have list chooser ( two lists and buttons) a text field, a combobox,two text area Can i fit all these in JDialog... hmm! i think i can!! :roll: Will this be a proper methodology... further! i want to invoke the parent Class function, how will i do this!!! In below Example!! i want to call X, how can i do this Thanks and Regards vinaya i.e public class A extends JFrame { somefunction() { //Call to B b.show(); } public void x() { } } public class B Extends JDialog { B() { .... .... setModal(true); .... } }
|
 |
Vinod Venugopal
Ranch Hand
Joined: Dec 06, 2000
Posts: 148
|
|
Hi Vinaya, Yes, u can make B ur Dialog & insert ur components in it. Then u can call b.show() where show() is public & b is an object of B class or u can make show() static & directly call B.show() in A. The advantage of latter is u dont have to instantiate B, just call it directly , this is used incase u need to call show lot of times so creating objects unnecessarily is undesirable. In the same way u can call A.X() where X() is a static method of A. Vinod
|
 |
 |
|
|
subject: Calling JFrame B from JFrame A
|
|
|