-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.4.2
-
x86
-
windows_2000
Name: gm110360 Date: 04/23/2004
FULL PRODUCT VERSION :
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)
FULL OS VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
JTextfield does not draw the proper background color to visually indicate when it is disabled via setEnabled(false) when using the Windows look and feel (haven't checked others).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code below
import javax.swing.*;
public class Test {
public static void main(String[] args) {
JFrame jf = new JFrame();
JTextField myField = new JTextField(10);
//below run code fixes the bug
//JTextFieldFixed myField = new JTextFieldFixed(10);
myField.setEnabled(false);
jf.getContentPane().add(myField);
jf.pack();
jf.show();
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
myField should have the same disabled background color as other components.
ACTUAL -
myField instead has a white background that look the same as an enabled field.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
It's easy enough to extend JTextfield to fix this -- but should I have to?
import javax.swing.*;
public class JTextFieldFixed extends JTextField {
public JTextFieldFixed(int value) {
super(value);
}
public void setEnabled(boolean b) {
super.setEnabled(b);
if (b) {
this.setBackground(UIManager.getColor("TextField.background"));
}
else {
this.setBackground(UIManager.getColor("TextField.inactiveBackground"));
}
}
}
(Incident Review ID: 214544)
======================================================================
- duplicates
-
JDK-4883120 Win L&F: Bug 4174290 not fixed. Disabled JTextField background should be grey
- Resolved