Now, I'm not sure whether this is possible or the best way to complete what I am trying to do But basically I'm making a very simple simulation program with very simple swing GUI
After each round of simulation, some buttons in the interface are able to make changes for the user and then To start the user simulation again The "release" button can suppress simulation is basically a time loop that has to wait for the user to take action before continuing. My question is how can I stop the program and why not wait until the user presses the "continue" button? Please tell me if there is any more details, then I can tell that it is not clear!
Edit:
I'm going to add some simple code here so maybe it will understand more. The program is in two parts, the simulation class and the view . The buttons pressed are in the view square, while the simulation is happening in its class.
Simulation class:
simulation view = new simulation view (); // JFrame increases while (! Some_condition) requires user action via {// code // button, press here before continuing! }
The best way to go most probably happens in a round of simulation method , Which will then be executed with the action listener, which you want is connected to the button.
After editing: Someone needs to control the simulation in the first place, so that you can do the following:
SimluationClass {public int startSim () {. ..}} class simulation view {SimulationClass sim = new SimulationClass (); Private Zero Init () {Jebton Button = New Pocket ("Start"); Button.addActionListener (new functionalist) (zero verbose (...) {sim.startSim ()}}); }}
Keep in mind that it will freeze your GUI because the SIM method will be executed from the event thread.
No comments:
Post a Comment