diff options
author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-17 18:09:40 +0000 |
---|---|---|
committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-17 18:09:40 +0000 |
commit | 2d8cf20d0d5ca6b1fbdefc22229d4b7cf1497ede (patch) | |
tree | c976ca91e3ef0bda3b34b37c0195145638d8d08e /libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java | |
parent | a3ef37ddfeddcc5b0f1c5068d8fdeb25a302d5cd (diff) | |
download | ppe42-gcc-2d8cf20d0d5ca6b1fbdefc22229d4b7cf1497ede.tar.gz ppe42-gcc-2d8cf20d0d5ca6b1fbdefc22229d4b7cf1497ede.zip |
Imported GNU Classpath 0.20
* Makefile.am (AM_CPPFLAGS): Add classpath/include.
* java/nio/charset/spi/CharsetProvider.java: New override file.
* java/security/Security.java: Likewise.
* sources.am: Regenerated.
* Makefile.in: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109831 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java')
-rw-r--r-- | libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java index b22aa15f901..288a8d89f7e 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java @@ -190,10 +190,19 @@ public class BasicComboBoxUI extends ComboBoxUI */ Dimension displaySize; - // FIXME: This fields aren't used anywhere at this moment. - protected Dimension cachedMinimumSize; + // FIXME: This field isn't used anywhere at this moment. protected CellRendererPane currentValuePane; - protected boolean isMinimumSizeDirty; + + /** + * The current minimum size if isMinimumSizeDirty is false. + * Setup by getMinimumSize() and invalidated by the various listeners. + */ + protected Dimension cachedMinimumSize; + + /** + * Indicates whether or not the cachedMinimumSize field is valid or not. + */ + protected boolean isMinimumSizeDirty = true; /** * Creates a new <code>BasicComboBoxUI</code> object. @@ -285,8 +294,7 @@ public class BasicComboBoxUI extends ComboBoxUI comboBox.addPropertyChangeListener(propertyChangeListener); focusListener = createFocusListener(); - comboBox.addFocusListener(focusListener); - listBox.addFocusListener(focusListener); + editor.addFocusListener(focusListener); itemListener = createItemListener(); comboBox.addItemListener(itemListener); @@ -563,6 +571,7 @@ public class BasicComboBoxUI extends ComboBoxUI { arrowButton.setEnabled(comboBox.isEnabled()); arrowButton.setFont(comboBox.getFont()); + arrowButton.setFocusable(false); } /** @@ -615,12 +624,14 @@ public class BasicComboBoxUI extends ComboBoxUI public void setPopupVisible(JComboBox c, boolean v) { if (v) - { - popup.show(); - popup.getList().requestFocus(); - } + popup.show(); else popup.hide(); + + if (comboBox.isEditable()) + editor.requestFocus(); + else + comboBox.requestFocus(); } /** @@ -668,7 +679,7 @@ public class BasicComboBoxUI extends ComboBoxUI /** * Returns the minimum size for this {@link JComboBox} for this - * look and feel. + * look and feel. Also makes sure cachedMinimimSize is setup correctly. * * @param c The {@link JComponent} to find the minimum size for. * @@ -676,10 +687,15 @@ public class BasicComboBoxUI extends ComboBoxUI */ public Dimension getMinimumSize(JComponent c) { - Dimension d = getDisplaySize(); - int arrowButtonWidth = d.height; - Dimension result = new Dimension(d.width + arrowButtonWidth, d.height); - return result; + if (isMinimumSizeDirty) + { + Dimension d = getDisplaySize(); + int arrowButtonWidth = d.height; + cachedMinimumSize = new Dimension(d.width + arrowButtonWidth, + d.height); + isMinimumSizeDirty = false; + } + return new Dimension(cachedMinimumSize); } /** The value returned by the getMaximumSize() method. */ @@ -1062,6 +1078,9 @@ public class BasicComboBoxUI extends ComboBoxUI */ public void focusGained(FocusEvent e) { + // Lets assume every change invalidates the minimumsize. + isMinimumSizeDirty = true; + hasFocus = true; comboBox.repaint(); } @@ -1074,6 +1093,9 @@ public class BasicComboBoxUI extends ComboBoxUI */ public void focusLost(FocusEvent e) { + // Lets assume every change invalidates the minimumsize. + isMinimumSizeDirty = true; + hasFocus = false; setPopupVisible(comboBox, false); comboBox.repaint(); @@ -1102,6 +1124,9 @@ public class BasicComboBoxUI extends ComboBoxUI */ public void itemStateChanged(ItemEvent e) { + // Lets assume every change invalidates the minimumsize. + isMinimumSizeDirty = true; + if (e.getStateChange() == ItemEvent.SELECTED && comboBox.isEditable()) comboBox.getEditor().setItem(e.getItem()); comboBox.repaint(); @@ -1149,6 +1174,9 @@ public class BasicComboBoxUI extends ComboBoxUI public void contentsChanged(ListDataEvent e) { // if the item is selected or deselected + + // Lets assume every change invalidates the minimumsize. + isMinimumSizeDirty = true; } /** @@ -1158,6 +1186,9 @@ public class BasicComboBoxUI extends ComboBoxUI */ public void intervalAdded(ListDataEvent e) { + // Lets assume every change invalidates the minimumsize. + isMinimumSizeDirty = true; + ComboBoxModel model = comboBox.getModel(); ListCellRenderer renderer = comboBox.getRenderer(); @@ -1179,6 +1210,9 @@ public class BasicComboBoxUI extends ComboBoxUI */ public void intervalRemoved(ListDataEvent e) { + // Lets assume every change invalidates the minimumsize. + isMinimumSizeDirty = true; + // recalculate display size of the JComboBox. displaySize = getDisplaySize(); comboBox.repaint(); @@ -1206,6 +1240,9 @@ public class BasicComboBoxUI extends ComboBoxUI */ public void propertyChange(PropertyChangeEvent e) { + // Lets assume every change invalidates the minimumsize. + isMinimumSizeDirty = true; + if (e.getPropertyName().equals("enabled")) { arrowButton.setEnabled(comboBox.isEnabled()); |