Reputation: 5959
I'm writing an application in which the user of the application switches between multiple windows or frames
(in java).
Is there any other way to switch between these frame
s instead of making a frame
visible to false/true
?
Upvotes: 1
Views: 825
Reputation: 9344
Does it actually need to be different Frames (or JFrames) or is it just different sets of content? Do you need separate MenuBars, Frame Titles, etc? Generally speaking, an Application can have a single frame with multiple panels of content that switch in and out (Possibly using something like a CardLayout.) There are certainly ways to do what you want - are you saying you want to keep the different Frames visible while just bringing a different one to the front? If so, all Frames have a toFront() call that will pop it to the front of the display order, but you'll need to deal with focus issues as well.
Upvotes: 4
Reputation: 115418
If window is not visible at the moment setVisible()
is the right way.
If window is invisible you can use requestFocus()
and requestForcusInWindow()
.
Upvotes: 1