Swing popup in Swing application

I have a Swing UI with a certain number of buttons. One button invokes a separate swing class, and a new window opens with new buttons and other functions. Now, when I close this window, the original window also closes. I think this is because both classes are impedmented

javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
//some code
}
}

Now how to overcome this? A sample code or link will be very helpful. Thanks

+3
source share
4 answers

It's hard to guess without seeing the code. Perhaps your JFrameinstalled setDefaultCloseOperationto close the application when the window is closed (perhaps EXIT_ON_CLOSE). See the java doc for more information on this.

From java doc :

EXIT_ON_CLOSE ( JFrame): , System exit. .

, . . ( ).

+7

SwingUtilities.invokeLater . - run, GUI .

EXIT_ON_CLOSE, , System.exit().

, EXIT_ON_CLOSE , . . Javadoc.

, setDefaultCloseOperation .

+3

, Swing, EDT Thread Dispatch Thread, SwingUtilities.invokeLater, , , , , , EDT. , , JButton ActionListener, SwingUtilities.invokeLater, actionPerformed EDT.

, JDialog - , , JFrame. JFrame , , .

, , JDialogs , , JFrame.

+1

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) JFrame.

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) , JFrame , EXIT_ON_CLOSE , JFrame .

0
source

All Articles