File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Switching b/w Frames Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Switching b/w Frames" Watch "Switching b/w Frames" New topic
Author

Switching b/w Frames

poornima sudharshan
Greenhorn

Joined: May 18, 2001
Posts: 18
I am concerned regarding how to switch b/w Frames.
Right now in my code,I pass an instance of the first JFrame to the second,& when you press the Back Button in the second screen,
what I am doing now is setting the setVisible to false for the current screen & make the setVisible to true for the first screen(by changing the instance of the first JFrame which has been passed to the second JFrame ).
My concern is if we have a ample number of screens,then it is surely bad design to keep passing objects from one JFrame to the other.
Is there any way out for me to implement this Back button logic?
Please clear this for me,
poornima.
Rick Fortier
Ranch Hand

Joined: Jun 04, 2001
Posts: 147
Originally posted by poornima sudharshan:
I am concerned regarding how to switch b/w Frames.
Right now in my code,I pass an instance of the first JFrame to the second,& when you press the Back Button in the second screen,
what I am doing now is setting the setVisible to false for the current screen & make the setVisible to true for the first screen(by changing the instance of the first JFrame which has been passed to the second JFrame ).
My concern is if we have a ample number of screens,then it is surely bad design to keep passing objects from one JFrame to the other.
Is there any way out for me to implement this Back button logic?
Please clear this for me,
poornima.

What if you had both JFrames as variables in your global area and just did frame.show() when needed? I have not done my GUI yet though.
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Take a look at your run of the mill wizard-like interface - you aren't seeing frames (windows) popping up and going to and fro between each other. You see a single window where different content pops up every time. With "Next" and "Previous" buttons you can browse through that content.
Once you have made up your mind on how the UI should work (but no earlier!), take a look at CardLayout.
- Peter
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Switching b/w Frames
 
Similar Threads
swing help
open JFrame from JDialog
frame problem
wrong output
awt - what does pack( ) do here?