We were having in correctly determining if a mouse click is inside or not of the current menu selection list. This lead to ComboBoxes closing too early, and not having the selection updated correctly.
We must:
1. also consider the first element in the current menu selection
2. consider the subcomponents of the selection (like when there's a list
inside a JPopupMenu, we not only check for the JPopupMenu but also for
the list. that's what happend with the JComboBox).
2006-03-18 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/MenuSelectionManager.java
(isComponentPartOfCurrentMenu): Also consider the first element
in a menu selection list. Make a isDescendentFrom check instead
of simple equals to also catch sub components.
/Roman
--
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/MenuSelectionManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/MenuSelectionManager.java,v
retrieving revision 1.12
diff -u -r1.12 MenuSelectionManager.java
--- javax/swing/MenuSelectionManager.java 12 Sep 2005 16:17:14 -0000 1.12
+++ javax/swing/MenuSelectionManager.java 19 Mar 2006 11:36:01 -0000
@@ -216,18 +216,34 @@
public boolean isComponentPartOfCurrentMenu(Component c)
{
MenuElement[] subElements;
- for (int i = 0; i < selectedPath.size(); i++)
+ boolean ret = false;
+ for (int i = 0; i < selectedPath.size(); i++)
{
- subElements = ((MenuElement) selectedPath.get(i)).getSubElements();
- for (int j = 0; j < subElements.length; j++)
- {
- MenuElement me = subElements[j];
- if (me != null && (me.getComponent()).equals(c))
- return true;
- }
+ // Check first element.
+ MenuElement first = (MenuElement) selectedPath.get(i);
+ if (SwingUtilities.isDescendingFrom(c, first.getComponent()))
+ {
+ ret = true;
+ break;
+ }
+ else
+ {
+ // Check sub elements.
+ subElements = first.getSubElements();
+ for (int j = 0; j < subElements.length; j++)
+ {
+ MenuElement me = subElements[j];
+ if (me != null
+ && (SwingUtilities.isDescendingFrom(c, me.getComponent())))
+ {
+ ret = true;
+ break;
+ }
+ }
+ }
}
- return false;
+ return ret;
}
/**
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
