Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Need help hiding a window...

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?
Ranch Hand
Posts: 15304
Mac OS X IntelliJ IDE Chrome
  • 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.
mooooooo ..... tiny ad ....
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic