JDK-5090094 : Non-editable JPasswordField not greyed out
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-08-20
  • Updated: 2004-09-13
  • Resolved: 2004-09-13
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 08/20/2004


FULL PRODUCT VERSION :
C:\WINDOWS\system32>java -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.


import javax.swing.*;

public class Password extends JPanel
{
    public Password()
    {
        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 );
        frame.show();
    }
}


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
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.
ACTUAL -
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.

REPRODUCIBILITY :
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) 
======================================================================

Comments
EVALUATION Possibly a duplicate of 5080144. ###@###.### 2004-08-23
23-08-2004