what the actionPerformed should pass to the while
Can you write a list of the steps the program should take to do what you want?
The normal GUI program shows the user a form and waits for the user's input. When the user clicks on a button the action listener method is called and it does some processing, perhaps prepares data and shows it to the user and exits to wait for the user to do more inputting.
Not sure where the loop you are talking about fits in this scheme.
The "loop" in the processing I described above would be between the display of the GUI, the action listener and then back to the display of the GUI.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
Did you understand what I meant by the "loop" in the program's processing?
Your code would not use a do while loop to wait for user input. Your code does a little bit, then exits and awaits an event from the user. When it gets an event, it does a little and then exits and waits for the next event.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
Running the do while is one thing.
Using GUI to get input from a user is something else.
If you used a loop, what would the code do when it is waiting for user input?
With the event driven method, your code is not executing at all. You use what the user inputs to control what code to execute.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
There are two fundamentally different approaches to this:
1. You run the program, then display the yes/no buttons. When the user clicks the "yes" button your event handler runs the program again. When he clicks "no" you exit. This approach doe NOT have an explicit loop
2. You start a loop. In it you run the program then you display a MODAL yes/no dialog which waits for the user to click a button. When a button is clicked you continue your loop or exit depending on which button. This approach does not have an event handler in your code (there is one, but it is handled within the modal dialog itself).
If your requirement is to use a loop, then approach 2 seems appropriate. Look at the showConfirmDialog(...) method in the JOptionPane class
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073