/[classpath]/classpath/javax/swing/plaf/basic/BasicMenuUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicMenuUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by abalkiss, Mon Jul 11 18:07:15 2005 UTC revision 1.12 by abalkiss, Mon Jul 11 19:15:27 2005 UTC
# Line 292  public class BasicMenuUI extends BasicMe Line 292  public class BasicMenuUI extends BasicMe
292        manager.processMouseEvent(e);        manager.processMouseEvent(e);
293      }      }
294    
295        private boolean popupVisible()
296        {
297          JMenuBar mb = (JMenuBar) ((JMenu)menuItem).getParent();
298          // check if mb.isSelected because if no menus are selected
299          // we don't have to look through the list for popup menus
300          if (!mb.isSelected())
301            return false;
302          for (int i=0;i<mb.getMenuCount();i++)
303            if (((JMenu)mb.getComponent(i)).isPopupMenuVisible())
304              return true;
305          return false;
306        }
307    
308      public void mouseEntered(MouseEvent e)      public void mouseEntered(MouseEvent e)
309      {      {
310        /* When mouse enters menu item, it should be considered selected        /* When mouse enters menu item, it should be considered selected
# Line 303  public class BasicMenuUI extends BasicMe Line 316  public class BasicMenuUI extends BasicMe
316                 it will be selected)                 it will be selected)
317        */        */
318        JMenu menu = (JMenu) menuItem;        JMenu menu = (JMenu) menuItem;
319        JMenuBar mb = (JMenuBar) menu.getParent();  
320        if (! menu.isTopLevelMenu()        // NOTE: the following if used to require !menu.isArmed but I could find
321            || (mb.isSelected() && (((JMenu)(mb.getComponent                    // no reason for this and it was preventing some JDK-compatible behaviour.
322                                             (mb.getSelectionModel().        // Specifically, if a menu is selected but its popup menu not visible,
323                                              getSelectedIndex()))).        // and then another menu is selected whose popup menu IS visible, when
324                                    isPopupMenuVisible()) && ! menu.isArmed()))        // the mouse is moved over the first menu, its popup menu should become
325          // visible.
326    
327          if (! menu.isTopLevelMenu() || popupVisible())
328          {          {
329            // set new selection and forward this event to MenuSelectionManager            // set new selection and forward this event to MenuSelectionManager
330            MenuSelectionManager manager = MenuSelectionManager.defaultManager();            MenuSelectionManager manager = MenuSelectionManager.defaultManager();

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26