Name: tb29552 Date: 06/17/97
Hello,
I intended to create a text field in which it is possible to
insert digits only. The source is appended below. The resulting
code screens some characters out (especially normal alphabetic
characters, a-z and A-Z for example), but it is still possible to
input some others (especially accented and special characters,
�������������� for example).
Is this a bug, or am I doing something wrong?
Thank you for your support.
import java.awt.*;
import java.awt.event.*;
class IntField extends TextField implements KeyListener {
IntField() {
addKeyListener(this);
}
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
char c = e.getKeyChar();
if ((c != '\b') & !Character.isDigit(c))
e.consume();
}
public static final void main(String[] args) {
Frame f = new Frame("IntField Test");
IntField i = new IntField();
f.add(i);
f.pack();
f.show();
}
}
company - BCEE , email - ###@###.###
======================================================================