This fixes colored ComboBoxes. We were not setting/updating the colors
of the ComboBox button and list correctly.
2006-03-21 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/plaf/metal/MetalComboBoxButton.java
(setEnabled): Update colors of button correctly.
* javax/swing/plaf/metal/MetalComboBoxUI.java
(MetalPropertyChangeListener.propertyChange): Update the colors
of the list and the button when any of the color properties
of the ComboBox change.
/Roman
--
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/plaf/metal/MetalComboBoxButton.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java,v
retrieving revision 1.9
diff -u -r1.9 MetalComboBoxButton.java
--- javax/swing/plaf/metal/MetalComboBoxButton.java 19 Mar 2006 11:04:20 -0000 1.9
+++ javax/swing/plaf/metal/MetalComboBoxButton.java 21 Mar 2006 14:57:47 -0000
@@ -199,8 +199,16 @@
public void setEnabled(boolean enabled)
{
super.setEnabled(enabled);
- // TODO: figure out what this might need to be used for
- // perhaps it has something to do with the button's icon and/or border?
+ if (enabled)
+ {
+ setBackground(comboBox.getBackground());
+ setForeground(comboBox.getForeground());
+ }
+ else
+ {
+ setBackground(UIManager.getColor("ComboBox.disabledBackground"));
+ setForeground(UIManager.getColor("ComboBox.disabledForeground"));
+ }
}
/**
Index: javax/swing/plaf/metal/MetalComboBoxUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalComboBoxUI.java,v
retrieving revision 1.11
diff -u -r1.11 MetalComboBoxUI.java
--- javax/swing/plaf/metal/MetalComboBoxUI.java 19 Mar 2006 11:04:22 -0000 1.11
+++ javax/swing/plaf/metal/MetalComboBoxUI.java 21 Mar 2006 14:57:47 -0000
@@ -38,6 +38,7 @@
package javax.swing.plaf.metal;
+import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
@@ -130,7 +131,7 @@
String name = e.getPropertyName();
if (name.equals("editable"))
editablePropertyChanged(e);
- if (name.equals("enabled"))
+ else if (name.equals("enabled"))
{
if (arrowButton instanceof MetalComboBoxButton)
{
@@ -139,6 +140,18 @@
comboBox.repaint();
}
}
+ else if (name.equals("background"))
+ {
+ Color c = (Color) e.getNewValue();
+ arrowButton.setBackground(c);
+ listBox.setBackground(c);
+ }
+ else if (name.equals("foreground"))
+ {
+ Color c = (Color) e.getNewValue();
+ arrowButton.setForeground(c);
+ listBox.setForeground(c);
+ }
}
}