Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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.

accepted

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.


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote