How to code the ActionListener/ActionPerformed to get desired result? I already
ID: 3543527 • Letter: H
Question
How to code the ActionListener/ActionPerformed to get desired result?
I already have a WorkerClass(TheaterSales.java)
The code is: http://dpaste.com/1408670/
So far my GUI Driver class is: http://dpaste.com/1408671/
Implement the ActionListener and provide an actionPerformed method
the sales and total sales fields should not be editabel(user cannot enter values)
A dialog message box should alert the user if any negative quantities are negative. If negative, do not diplay sales and total sales
sales and total sales must be in currency format.
It creates a TheaterSales object and uses method for calculating the sales and total sales
Explanation / Answer
For that I have written the following code in the "ActionPeformed(...)" method of the "Start" button
You need that code to be in the actionPerformed(...) of the ActionListener registered with the Start button, not for the Start button itself.
You can add a simple ActionListener like this:
note that your startButton above will need to be final in the above example if you want to create the anonymous listener in local scope.
For that I have written the following code in the "ActionPeformed(...)" method of the "Start" button
You need that code to be in the actionPerformed(...) of the ActionListener registered with the Start button, not for the Start button itself.
You can add a simple ActionListener like this:
JButton startButton = new JButton("Start"); startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { startButton.setEnabled(false); stopButton.setEnabled(true); } } ); note that your startButton above will need to be final in the above example if you want to create the anonymous listener in local scope.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.