Bookmark Topic Watch Topic
  • New Topic

How to switch frame use JButton?

 
taiki bao
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Report post to moderator
Dear All!!
I suffer a trouble in UI design. I got several frames in the project, nearly finished the function in each single frame, but i cannot link them together.
for example: First frame1 = new First();
CheckIn frame2 = new CheckIn();

void jButton1_actionPerformed(ActionEvent e) {???}
what can i write into {???} to implement "press button in First frame then go to CheckIn frame?"

many thanks!!!
 
satya sahu
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
I don't know your requirement.
But i think your approach is wrong.
For a particular project you should use a single Frame and for all other screens you should use either JDialo or JPanel....

the second class should be like this.
CheckingClass extends JPanel/JDialog

It should be instantiated inside the button pressed method.
Like :
CheckingClass obj = new CheckingClass()
obj.show();
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Report post to moderator
Having multiple frames is fine as long as it is logical to the user. All you should have to do is
frame1.hide()
frame2.show()

unless I'm not understanding the question.

I'm not sure what you mean by 'press button in First frame'. Where you have the ??? appears to be the ActionListener attached to the button so it would have been pressed.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
taiki bao,

You have already asked this question and received some good advice here. Plese do not post the same question more than once. It makes it hard for people to follow and help.

Thanks.
 
    Bookmark Topic Watch Topic
  • New Topic