• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Switching b/w Frames

 
poornima sudharshan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic