Page 1 of 1

5 10 11 12 15 16 17 18 19 20 22 23 1 import java.awt.event.* 2 import javax.swing.*; 4 public class LockerApp extends Lo

Posted: Sun May 15, 2022 2:10 pm
by answerhappygod
5 10 11 12 15 16 17 18 19 20 22 23 1 Import Java Awt Event 2 Import Javax Swing 4 Public Class Lockerapp Extends Lo 1
5 10 11 12 15 16 17 18 19 20 22 23 1 Import Java Awt Event 2 Import Javax Swing 4 Public Class Lockerapp Extends Lo 1 (235.38 KiB) Viewed 68 times
5 10 11 12 15 16 17 18 19 20 22 23 1 import java.awt.event.* 2 import javax.swing.*; 4 public class LockerApp extends Locker implements ActionListener { Timer timer = new Timer (10, this); int state = 0; LockerApp() { 9 for (int i = 0; i<=11; i++) b.addActionListener(this); } public void actionPerformed (ActionEvent e) { 13 switch (state)! 14 case 0: if (e.getSource ()==b[7]) state - 1; break; case 1: if (e.getSource () ==b[0]) state = 2; 21 else if (e.getSource () ==b[7]) state = 1; else 24 state = 0; break; case 2: if (e.get Source () ==b[10]) { 28 timer.start(); } else if (e.getSource () ==b[7]) state = 1; else state = 0; break; 34 if (e.getSource () ==timer) { h = h+1; 37 if(h>=197) { h = 197; timer.stop(); timer.removeActionListener(this); } 42 repaint(); 43 44 45 public static void main(String[] args) { 46 new LockerApp(); 47 } 48 ) NNNNNNNNNMmmmmmmmmm HM000 ONMOONMOONMOONM00 25 26 27 29 30 31 32 33 35 36 38 39 40 41

11.1 Identify the listener used in this program. (1 point) 11.2 Name all source objects that fire an ActionEvent object listened to by the listener. (Your scores will be deducted for incorrect answers.) (1 point) 11.3 Trace the source code and explain step-by-step what is going on inside Locker App when a user runs the program and performs the following actions. First, the user clicks 0, then she clicks 7, then she clicks 7 again, then she clicks 0, and finally, she clicks X. (4 points) 11.4 What is the role of the property h? (1 point) 11.5 When does the timer start? When does it stop? (1 point) 11.6 Describe what happens after the timer starts comprehensively and concisely. (2 points)