• Post Reply Bookmark Topic Watch Topic
  • New Topic

switching between Swing Classes  RSS feed

 
Gary Frick
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to return to a previous class that defines it's own GUI interface? In other words, my application consists of a several windows that are each invoked/instantiated by the previous GUI class. So each class file defines its own separate window environment. Each window accepts input and passes those values on when it instatiates the next GUI window. However I want to be able to traverse backwards to previous window and maintain its previous state and variables. I'm not sure if this is possible. As I go forward and backward I want to make each window visible or invisble depending upon who is active or not active.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, when you said visble and invisible, you pretty much stated what you need to do.
Here is what I would do.
When one frame is open and then you pass information to the next frame then set the current frame's visibility to false setVisible(false). That way the Frame is still there, and all the variables and components won't change. Also, as part of the arguments you are passing, pass the Frame object or some reference to where the new frame was instantiated from to the next frame. Then you always have a reference to what frame you came from, and if you need to go back, just setVisible(true). Then, at some point, you will need to clean up loose ends and dispose() of whatever frames you can dispose of.
Anyway, that is a on the fly solution. There are probably better ways, and if I think of one, I will edit my response.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!