Results 1 to 5 of 5

Thread: Event Listeners{resolved}

Threaded View

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Event Listeners{resolved}

    I copied this program right out of the book and I keep getting an error about something not being an abstract method and not overriding one.

    Here is the code for the program:

    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;

    class KeyView extends JFrame implements KeyListener {

    JTextField keyText = new JTextField(80);
    JLabel keyLabel = new JLabel("Press any key in the text field");

    KeyView() {
    super("KeyView");
    setSize(350,100);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    keyText.addKeyListener(this);
    Container pane = getContentPane();
    BorderLayout bord = new BorderLayout();
    pane.add(keyText, BorderLayout.NORTH);
    pane.add(keyLabel, BorderLayout.CENTER);
    setContentPane(pane);
    setVisible(true);

    }

    public void KeyTyped(KeyEvent input) {
    char key = input.getKeyChar();
    keyLabel.setText("You pressed " + key);
    }

    public void keyPressed(KeyEvent txt) {
    //do nothing
    }
    public void keyReleased(KeyEvent txt) {
    //do nothing
    }

    public static void main(String[] arguments) {
    KeyView frame = new KeyView();
    }
    }

    This is the error message I get

    KeyView is not abstract and does not override abstract method keyTyped(java.awt.event.KeyEvent) in java.awt.event.KeyListener
    class KeyView extends JFrame implements KeyListener {




    Somebody pleeeeeeeaaaase help me...
    Last edited by Dilenger4; Jun 6th, 2004 at 09:54 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width