-
Bug
-
Resolution: Fixed
-
P2
-
1.3.0
-
kestrel
-
x86
-
windows_nt
Name: skT88420 Date: 10/12/99
This took me forever to find this one!
Bring up this example. The field created last will have a
non functional backspace and delete key. The KeyListener
did not provide me with any meaningful information to tell you,
but I left it in there in case it does for you.
----------------------
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class SunTest17 extends JFrame {
public SunTest17() {
super("JPasswordField");
JTextField tf;
JPasswordField pf;
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
KeyListener l = new KeyAdapter() {
public void keyPressed(KeyEvent e) {
System.out.println("PRESSED in " + e.getSource().getClass());
System.out.println("Char: " + e.getKeyChar() + " Code: " + e.getKeyCode());
}
public void keyTyped(KeyEvent e) {
System.out.println("TYPED in " + e.getSource().getClass());
System.out.println("Char: " + e.getKeyChar() + " Code: " + e.getKeyCode());
}
};
/*
Change this to if (false) and the JPasswordField will not work.
Change this to if (true) and the JTextField field will not work.
*/
if (true) {
pf = new JPasswordField(10);
tf = new JTextField(10);
}
else {
tf = new JTextField(10);
pf = new JPasswordField(10);
}
tf.addKeyListener(l);
pf.addKeyListener(l);
panel.add( new JLabel("Text: "));
panel.add( tf);
panel.add( new JLabel("Password: "));
panel.add( pf );
getContentPane().add(panel);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public static void main(String[] args) {
SunTest17 s = new SunTest17();
s.pack();
s.setSize(400,300);
s.show();
}
}
(Review ID: 96433)
======================================================================