[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: BasicComboBoxUI - listener updates
From: |
David Gilbert |
Subject: |
[cp-patches] FYI: BasicComboBoxUI - listener updates |
Date: |
Sun, 18 Sep 2005 15:21:35 +0000 |
User-agent: |
Mozilla Thunderbird 1.0.6 (X11/20050728) |
I committed this patch:
2005-09-18 David Gilbert <address@hidden>
* javax/swing/plaf/basic/BasicComboBoxUI.java
(installListeners): add listener to arrowButton instead of comboBox,
deleted call to configureArrowButton(),
(uninstallListeners): remove listener from arrowButton instead of
comboBox, and deleted call to unconfigureArrowButton(),
(configureArrowButton): set font and enabled state, deleted
addMouseListener() call,
(unconfigureArrowButton): deleted removeMouseListener() call,
(MouseHandler.mousePressed): just toggle display status of popup,
(MouseHandler.mouseReleased): deleted.
The configureArrowButton() method adds a listener to the button - I've moved this to
the installListeners() method, replacing the listener that is added to the comboBox
(because BasicComboPopup takes care of adding a listener to the comboBox). Likewise
for removing the listener. The configureArrowButton() is changed to set the enabled
status of the button, as well as the font (not necessary for the BasicLookAndFeel,
but it seems to help with the MetalLookAndFeel). The MouseHandler is simplified to
just toggle the appearance of the popup menu.
Regards,
Dave
Index: javax/swing/plaf/basic/BasicComboBoxUI.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java,v
retrieving revision 1.14
diff -u -r1.14 BasicComboBoxUI.java
--- javax/swing/plaf/basic/BasicComboBoxUI.java 18 Sep 2005 13:39:54 -0000
1.14
+++ javax/swing/plaf/basic/BasicComboBoxUI.java 18 Sep 2005 13:55:33 -0000
@@ -289,13 +289,11 @@
comboBox.addKeyListener(keyListener);
mouseListener = createMouseListener();
- comboBox.addMouseListener(mouseListener);
+ arrowButton.addMouseListener(mouseListener);
// install listeners that listen to combo box model
listDataListener = createListDataListener();
comboBox.getModel().addListDataListener(listDataListener);
-
- configureArrowButton();
}
/**
@@ -339,13 +337,11 @@
comboBox.removeKeyListener(keyListener);
keyListener = null;
- comboBox.removeMouseListener(mouseListener);
+ arrowButton.removeMouseListener(mouseListener);
mouseListener = null;
comboBox.getModel().removeListDataListener(listDataListener);
listDataListener = null;
-
- unconfigureArrowButton();
}
/**
@@ -555,7 +551,8 @@
*/
public void configureArrowButton()
{
- arrowButton.addMouseListener(mouseListener);
+ arrowButton.setEnabled(comboBox.isEnabled());
+ arrowButton.setFont(comboBox.getFont());
}
/**
@@ -565,7 +562,6 @@
*/
public void unconfigureArrowButton()
{
- arrowButton.removeMouseListener(mouseListener);
}
/**
@@ -1270,38 +1266,7 @@
public void mousePressed(MouseEvent e)
{
if (comboBox.isEnabled())
- {
- if (e.getSource() instanceof JComboBox)
- {
- arrowButton.getModel().setPressed(true);
- arrowButton.getModel().setArmed(true);
- }
-
- comboBox.repaint();
-
- if (e.getSource() instanceof BasicArrowButton)
- toggleOpenClose();
- }
- }
-
- /**
- * This method is invoked when mouse is released over the combo box. It
- * repaints the combo box accordinglly
- *
- * @param e the MouseEvent
- */
- public void mouseReleased(MouseEvent e)
- {
- if (comboBox.isEnabled())
- {
- if (e.getSource() instanceof JComboBox)
- {
- arrowButton.getModel().setPressed(false);
- arrowButton.getModel().setArmed(false);
- }
-
- comboBox.repaint();
- }
+ toggleOpenClose();
}
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: BasicComboBoxUI - listener updates,
David Gilbert <=