• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Swing closing window

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I have JDialog and in that JDialog I have JPanel and in that JPanel i have button and i would like to close JDialog after pressing that button. I couldn't find any informations about this. Only thing i know is how to close that JPanel with but it closes only JPanel and JDialog still stays.
 
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lee,
The setVisible(false) only hides the dialog, you can see that by doing a setVisible(true) and it comes right back, you need to do a dispose() to make it close and be available to the GC.
Les

Lee Lares wrote:Hello, I have JDialog and in that JDialog I have JPanel and in that JPanel i have button and i would like to close JDialog after pressing that button. I couldn't find any informations about this. Only thing i know is how to close that JPanel with but it closes only JPanel and JDialog still stays.

 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i would like to close JDialog after pressing that button



You need to close the dialog NOT the panel.

To access the dialog you can add the following in the ActionListener of your button:

reply
    Bookmark Topic Watch Topic
  • New Topic