Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the question on the mext page refer to the complete class shown below which compiles with no uns with no exceptions but does not

image text in transcribed
image text in transcribed
For the question on the mext page refer to the complete class shown below which compiles with no uns with no exceptions but does not produce correet results: 3. (15 points) Event Driven Programming implements ActionListener 11 public final c 12 13 lass EventDrivenProgranming extends JPanel private static final String ENABLED STRING -"Click Me!" private static final S "Thanks!", tring DISABLED-STRNG . 1 6 17 private JButton myButtona private JButton myOtherButton 18 19 20 public EventDrivenProgramming) t 21 super myButton new JButton (ENABLED STRING) myOtherButton-new 23 24 25 26 on -new JButton (DISABLED STRING) setup ) 27 Private void setup) 28 29 30 31 32 add (myButton) add (myotherButton) myOtherButton.setEnabled (false) i 34 35 36 90verride publie void actionPerformed (final ActionEvent theEvent) f toggleButtonTextl) myButton.setEnabled(!myButton.isEnabled) myotherButton.setEnabled ( !myOtherButton.isEnabled )) 37 38 39 40 private void toggleButtonText) 41 42 43 if (myButton.isEnabled)) myButton.setText (DISABLED STRING) myOtherButton.setText (ENABLED STRING) elset 45 4 6 47 48 49 myButton.setText (ENABLED STRING): myotherButton.setrext (DISABLED STRING) 50 public static void main(final Stringt] theArgs) 51 52 53 54 final JFrame frame -new JFrame ("Event Driven Programming") frame.add (new EventDrivenProgramming()): frame.setSize (new Dimension (300, 75)) frame.setDefaultCloseoperation (JFrame.EXIT ON CLOSE) frame.setLocationRelativeTo (null); frame.setVisible (true); 56 57 58 e code on the previous page should produce a GUI with 2 buttons which change text and enable/disable when are clicked as shown below: The expected initial condition Event Driven Programming Click Me! The ted condition after clicking the enabled button Event Driven Programming Thanks Click Me The expected condition after clicking the enabled button Event Driven Programming Click Me Thanks Notice how the button text and enabled/disabled state change after a button click. Continuing to click the enabled button should cause the GUI to continue to alternate between the two states shown above. ithout crrors, runs without exceptions, and displays the GUI corcctly, but the GUI does not function correctly. Clicking on the buttons in the current code produces no visible change in the GU

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions