multithreading - How to pause execution of a program until a button is clicked in Java Swing -


I have a program with a GUI that needs to open a separate window and choose the user and wait for the option, then Continue. I think I should do this with waiting () and inform () the way, but I'm still trying to use them to actually find out a complex fact that the other thing is different When the second window is executed () in the method, it needs to be done.

Here's how I feel that it should be done here, apparently it is not quite right ...

With this button pressed the button Make a window, the button button should be pressed, another window should be created with one button, and when that button is pressed, the program "End".

Import java.awt.Dimension; Import java.awt.event.ActionEvent; Import java.awt.event.ActionListener; Import javax.swing *; Public class WtfExample {public static zero main (string [] args) {JFrame jf = new JFrame (); Pocket button = new pocket ("button"); But.Edition Listener (new executiveist) {Public Zero ActionPerfect (Action Event E) {WTFXMon We = New WTFXMon; We DISplay (;;}}); . Jf.getContentPane () add (butt); Jf.setSize (new dimension (1000, 500)); Jf.setVisible (true); Println ("Finished"); } Public synchronized zero performance () {JFrame jf = New JFrame (); Pocket button = new pocket ("button"); But.Edition Listener (new executiveist) {public zero functioning (Action Avenger E) {synchronize (WtfExample.this) {WtfExample.this.notifyAll ()}}}}); . Jf.getContentPane () add (butt); Jf.setSize (new dimension (1000, 500)); Jf.setVisible (true); While (true) {try {this.wait (); } Grip (Interrupted e) e.printStackTrace (); break; Edit}}

Edit - I was not quite clear in one thing - the other window that was open is empty, as if its components were never added to it. This is a matter whether it is a frame or a dialogue, but it only happens if the window is created from the methodical method.

No, you should use just one.


Comments

Popular posts from this blog

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

mysql - Can mysql_pconnect be called multiple times in one php page? -