Question: /java programming; Joyce Farrell; 8th ed //debugging exercises //output, need to fix //chapter 15 Advance GUI 1 // Lets user type keys 2 // Displays

/java programming; Joyce Farrell; 8th ed

//debugging exercises //output, need to fix

//chapter 15 Advance GUI

1 // Lets user type keys 2 // Displays each key typed 3 import javax.swing.*; 4 import java.awt.event.*; 5 import java.awt.*; 6 public class DebugFifteen3 extends JFrame implements KeyListener 7 { 8 char key; 9 Container con = null; 10 GridLayout grid = new GridLayout(2, 1); 11 JLabel label = new JLabel("Key Typed:"); 12 JTextArea textArea = new JTextArea(4, 25); 13 public DebugFifteen3() 14 { 15 setTitle("Debug Key Frame"); 16 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 17 con.setLayout(grid); 18 con.add(textArea); 19 con.add(label); 20 addKeyListener(this); 21 textArea.addKeyListener(this); 22 } 23 24 @Override 25 public void keyTyped() 26 { 27 char c = e.getKeyChar(); 28 label.setText ("Key Typed: " + c); 29 } 30 31 @Override 32 public void keyReleased(KeyEvent e) 33 { 34 } 35 36 public static void main(String[] args) 37 { 38 DebugFifteen3 kFrame = new DebugFifteen3(); 39 kFrame.setSize(300, 200); 40 kFrame.setVisible(true); 41 } 42 } 43 44 45

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!