-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta
-
x86, sparc
-
linux, solaris_2.6, windows_nt
-
Verified
Name: kaC94536 Date: 12/10/99
Interactive test JPasswordFieldTest0006 from
JCK-runtime-api-122/tests/api/javax_swing/interactive/JPasswordFieldTests.java
doesn't repaint JPasswordField component immediately after setting new echo
character. This produces malformed mix of old and new echo characters while
editing JPasswordField component.
===============================================================================
After an evaluation and a smaller sample code, I've determined that this is
a JDK bug and re-assigned it to the JDK Swing team.
The following sample code should display the problem.
1. Change the echoChar let's say to '$'. Be sure to enter a Return.
2. Click the JPasswordField, you'll see a jumble of old echoChar as well
as some new one.
3. Click the button "Repaint JPasswordField" or resize the frame and
JPasswordField will display only the new echoChar.
Roger Pham 12/15/99
---------------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class JPW extends JFrame implements ActionListener {
JPasswordField jpf = new JPasswordField("Secret Password", 25);
JTextField jtf = new JTextField("%", 2);
JTextField val = new JTextField(25);
public JPW() {
Container c = getContentPane();
c.setLayout(new GridLayout(3, 1));
JPanel p = new JPanel(new FlowLayout());
p.add(new JLabel("JPasswordField"));
p.add(jpf);
c.add(p);
p = new JPanel(new FlowLayout());
p.add(new JLabel("Enter EchoChar, 0 for for no echo:"));
p.add(jtf);
c.add(p);
JButton b = new JButton("Repaint JPasswordField");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jpf.repaint();
}
});
p.add(b);
p = new JPanel(new FlowLayout());
p.add(new JLabel("The text behind the JPasswordField:"));
p.add(val);
c.add(p);
jtf.addActionListener(this);
jpf.addActionListener(this);
jpf.setEchoChar(jtf.getText().charAt(0));
val.setText(new String(jpf.getPassword()));
}
public static void main(String argv[]) {
JFrame frame = new JPW();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
frame.setTitle("JPasswordField Test");
frame.pack();
frame.setSize(500, 200);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
char c = jtf.getText().charAt(0);
if (c == '0')
jpf.setEchoChar((char) 0);
else
jpf.setEchoChar(jtf.getText().charAt(0));
val.setText(new String(jpf.getPassword()));
}
}
Name: skT88420 Date: 01/07/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-I)
Java HotSpot(TM) Client VM (build 1.3-I, mixed mode)
javax.swing.JPasswordField jPF_password = new javax.swing.JPasswordField();
I initialize this JPasswordField component with a default value (e.g.: toto).
If I set the focus on this component, I cannot use arrows (cursor) keys.
I cannot use remove and delete keys too !!!
(Review ID: 99699)
======================================================================