Name: gm110360 Date: 08/20/2004
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Windows XP Look & Feel only
A DESCRIPTION OF THE PROBLEM :
In the Windows XP Look & Feel, when a JTextField is disabled, its background is greyed out. When a JPasswordField is disabled, it isn't greyed out.
This bug is similar to an old one (4336210) which appeared in other LAFs. However, in this case the font of a disabled JPasswordField changes in the same way as that of a JTextField, so it is only one half of that problem.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Select the Windows Look and Feel on Windows XP with the XP theme.
Create a JTextField and a JPasswordField, both initialized with some text.
Disable both of them.
public class Password extends JPanel
JTextField f1 = new JTextField( 10 );
JPasswordField f2 = new JPasswordField( 10 );
f1.setEditable( false );
f2.setEditable( false );
add( f1 );
add( f2 );
public static void main( String args )
JFrame frame = new JFrame();
frame.getContentPane().add( new Password() );
frame.setSize( 100, 300 );
EXPECTED VERSUS ACTUAL BEHAVIOR :
Disabling the JTextField and the JPasswordField should change them in such a way as to reflect their state. The nature of the change should be essentially the same in both cases.
Both fields reflect their being disabled by a grey font color. But only one the JTextField gets a grey background. The background of the JPasswordField is still white.
It is impossible to find out whether a JPasswordField with no text in it is disabled just by looking at it, because you cannot see the changed font color.
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Manually set the background color of JPasswordField when calling setEnabled() on it. But take care to first check that you are in the Windows LAF and that Windows is using the XP theme.
(Incident Review ID: 227110)