wood burning stoves 2.0
The moose likes Swing / AWT / SWT and the fly likes How to switch frame use JButton? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic

How to switch frame use JButton?

taiki bao

Joined: Apr 01, 2005
Posts: 4
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

Joined: Mar 26, 2003
Posts: 97
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()
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
Having multiple frames is fine as long as it is logical to the user. All you should have to do is

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

Joined: Jul 11, 2001
Posts: 15302

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.


GenRocket - Experts at Building Test Data
I agree. Here's the link: http://aspose.com/file-tools
subject: How to switch frame use JButton?
It's not a secret anymore!