Index: javax/swing/plaf/basic/BasicTextUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTextUI.java,v retrieving revision 1.34 diff -u -r1.34 BasicTextUI.java --- javax/swing/plaf/basic/BasicTextUI.java 25 Aug 2005 20:32:02 -0000 1.34 +++ javax/swing/plaf/basic/BasicTextUI.java 8 Sep 2005 11:58:20 -0000 @@ -38,6 +38,7 @@ package javax.swing.plaf.basic; +import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Graphics; @@ -342,10 +343,14 @@ public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("document")) - { + { // Document changed. - modelChanged(); - } + modelChanged(); + } + else if (event.getPropertyName().equals("enabled")) + { + updateComponentColors(); + } } } @@ -425,6 +430,30 @@ DocumentHandler documentHandler = new DocumentHandler(); /** + * The standard foreground color. This is the color which is used to paint + * text in enabled text components. + */ + Color foreground; + + /** + * The standard background color. This is the color which is used to paint + * text in enabled text components. + */ + Color background; + + /** + * The inactive foreground color. This is the color which is used to paint + * text in disabled text components. + */ + Color inactiveForeground; + + /** + * The inactive background color. This is the color which is used to paint + * text in disabled text components. + */ + Color inactiveBackground; + + /** * Creates a new BasicTextUI instance. */ public BasicTextUI() @@ -507,13 +536,18 @@ String prefix = getPropertyPrefix(); UIDefaults defaults = UIManager.getLookAndFeelDefaults(); - textComponent.setBackground(defaults.getColor(prefix + ".background")); - textComponent.setForeground(defaults.getColor(prefix + ".foreground")); textComponent.setMargin(defaults.getInsets(prefix + ".margin")); textComponent.setBorder(defaults.getBorder(prefix + ".border")); textComponent.setFont(defaults.getFont(prefix + ".font")); caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate")); + + // Fetch the colors for enabled/disabled text components. + foreground = defaults.getColor(prefix + ".foreground"); + background = defaults.getColor(prefix + ".background"); + inactiveForeground = defaults.getColor(prefix + ".inactiveForeground"); + inactiveBackground = defaults.getColor(prefix + ".inactiveBackground"); + updateComponentColors(); } /** @@ -1042,5 +1076,23 @@ return; View view = factory.create(elem); setView(view); + } + + /** + * Updates the colors of the text component according to its enabled + * state. + */ + void updateComponentColors() + { + if (textComponent.isEnabled()) + { + textComponent.setForeground(foreground); + textComponent.setBackground(background); + } + else + { + textComponent.setForeground(inactiveForeground); + textComponent.setBackground(inactiveBackground); + } } } Index: javax/swing/plaf/metal/MetalLookAndFeel.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,v retrieving revision 1.48 diff -u -r1.48 MetalLookAndFeel.java --- javax/swing/plaf/metal/MetalLookAndFeel.java 6 Sep 2005 21:24:57 -0000 1.48 +++ javax/swing/plaf/metal/MetalLookAndFeel.java 8 Sep 2005 11:58:20 -0000 @@ -865,6 +865,12 @@ "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1), "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6), + "TextField.border", MetalBorders.getTextFieldBorder(), + // These color values match the JDK1.5. However, this differs from + // previous JDKs. + "TextField.inactiveBackground", new ColorUIResource(238, 238, 238), + "TextField.inactiveForeground", new ColorUIResource(184, 207, 229), + "ToggleButton.background", new ColorUIResource(getControl()), "ToggleButton.border", MetalBorders.getButtonBorder(), "ToggleButton.darkShadow", new ColorUIResource(getControlDarkShadow()),