Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Calling JFrame B from JFrame A

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
{

}
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
vinaya kumar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Wanna see my flashlight? How about this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic