File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic
Author

How to switch frame use JButton?

taiki bao
Greenhorn

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
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

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
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

Joined: Jul 11, 2001
Posts: 15300
    
    6

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.


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