Java Swing closes ONLY one application

Hi everyone: I have a Java Swing application. There is a button that allows the user to create the opening of a new application window. I use System.Exit (0) when the user decides to close the application, however, when I click the Close button, both application windows close.

public static void main(String[] args)  
{       
 ghMain = new GreenHouseMain();     
}

The above describes how I initialize the first application and then use the same code to create a new GreenHouseMain object to open the second application window.

So my question is how to close only one application window from which I clicked the close button?

Thank you all

+3
source share
3 answers

dispose() System.exit() Window, . , Event Dispatch .

+3

, - JFrames. , , JDialog, . , , , , , , 100% , . , , .

+1

javadocs setDefaultCloseOperation. System.exit() , , .

+1

Source: https://habr.com/ru/post/1781337/


All Articles