• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

switching between Swing Classes

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic