6 700 OO N 16 import javax.swing.*; 2 import java.awt.*; 3 import java.awt.event.*; 4 5 public class TextMove extends JP

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

6 700 OO N 16 import javax.swing.*; 2 import java.awt.*; 3 import java.awt.event.*; 4 5 public class TextMove extends JP

Post by answerhappygod »

6 700 Oo N 16 Import Javax Swing 2 Import Java Awt 3 Import Java Awt Event 4 5 Public Class Textmove Extends Jp 1
6 700 Oo N 16 Import Javax Swing 2 Import Java Awt 3 Import Java Awt Event 4 5 Public Class Textmove Extends Jp 1 (177.6 KiB) Viewed 65 times
q = 2
6 700 OO N 16 import javax.swing.*; 2 import java.awt.*; 3 import java.awt.event.*; 4 5 public class TextMove extends JPanel implements ActionListener { JFrame f = new JFrame ("Changing Location"); 8 JPanel p = new JPanel(); 9 JButton u = new JButton ("up"); 10 JButton d = new JButton ("down"); 11 int y = 115; 12 TextMove () { 13 p.setLayout (new GridLayout(2,1)); 14 p.add(u); 15 p.add(d); u.addActionListener(this); 17 d.addActionListener(this); 18 f.add(this,BorderLayout.CENTER); 19 f.add (p, BorderLayout.EAST); 20 f.setSize (480,200); 21 f.setVisible(true); 22 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 24 protected void paint Component (Graphics g) { 25 g. setFont (new Font ("Sans Serif", Font.BOLD, 100)); 26 g.drawstring("TEST",70,y); } public void action Performed (ActionEvent e) { if (e.getSource() == u) y - y - 5; repaint(); } 33 public static void main(String[] args) { 34 new TextMove(); } | 23 27 28 29 30 31 32 OWN PO 35 36

9.1 Identify the listener used in this program. (1 point) 9.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) 9.3 When is the method actionPerformed(ActionEvent e) called? (1 point) 9.4 What would happen if the method actionPerformed(ActionEvent e) was not implemented in the class TextMove? Explain your reasoning. (1 point) 9.5 What is the purpose of the following statement? (1 point) u.addActionListener(this); 9.6 The output after running this class is shown in the figure (top), and the result after clicking the up button three times is shown in figure (bottom). Explain what causes such the result. And explain how to fix the problem. (4 points) Changing Location 0 x up TEST down Changing Location a X up TEST down 9.7 Modify the source code so that when a user clicks the down button, the text moves down by q pixels at a time, where q is the last digit of your student ID. (For example, if your student ID is 6022300153, then q is 3.) (3 points)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply