[2442] in java-interest

home help back first fref pref prev next nref lref last post

Events and Text widgets

daemon@ATHENA.MIT.EDU (Steve Wong - aka the Ninja)
Mon Oct 2 21:18:19 1995

From: Steve Wong - aka the Ninja <Steven.Wong@Comp.VUW.AC.NZ>
To: java-interest@java.sun.com
Date: Tue, 03 Oct 1995 10:50:07 +1300

hi,
	i'm having some problems trying to wrap my mind around how the
JDK api handles events. i'm using the JDK and X11R6, if that helps.

I want to be able to make a new TextField that allows me to configure
what happens when keys are pushed. Preferably after I take the
appropriate steps, i'd like to be able to pass a message back to the
parent Applet of the TextField.

however, when i try to override the boolean int keyDown(Event,int)
method, the method never seems to get called.

help/suggestions anyone?

	thanks,
		steve


//---------- NewTextField.java ----------

import java.awt.TextField;
import java.awt.Event;

public class NewTextField extends TextField {
  public MyTextField(String text, int cols) {
    super(text,cols);
  };

  public boolean keyDown(Event evt,int key) {
    System.out.println("keydown!: " + evt.toString() + " key: " + key);
    
    return true;
  };

};


//---------- NewTextFieldTest.java ----------

import java.applet.Applet;
import java.lang.System;
import NewTextField;

public class NewTextFieldTest extends Applet {
    MyTextField userTextInput;

    public NewTextFieldTest() {
      userTextInput = new MyTextField("hello!",80);
      add(userTextInput);
    }

    public void init() {
      resize(500,50);
    };
}


//---------- NewTextField.html ----------

<title>argh!</title>
<hr>
<applet code=NewTextFieldTest.class width=500 height=50>
</applet>
<hr>



-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post