• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help hiding a window...  RSS feed

 
Bigglesworth Naruki
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My GUI application opens a second window to allow the user to enter several details. I've setDefaultCloseOperation(HIDE_ON_CLOSE) so that the window contents are available to the main window at any time.
When they click the X button in the title bar, it hides as it is supposed to.
I want to add an actual OK button to allow them to "close" the screen normally. When I use the button's ActionEvent to setVisible(false) for the RootPane, it just hangs, and the OK button has the "pushed" look - as though it hasn't popped back up yet.
I know there has to be a programmatic way of hiding the frame with a JButton push that actually works, but I can't seem to find any references to it.
Any suggestions?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's because you are setting the RootPane's visibility to false. You need to set the actual Window to false. So myWindow.setVisible(false). By hiding the root pane, you are hiding the contents of the container IN the Window. The reason you are seeing your pressed button and nothing else is because that is the last operation visible before you hid the root pane. If you had hidden the root pane and then validated it, you would have seen the button as well as any other components disappear but not the Window.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!