Example #1
0
 public boolean isMenuBarPopup(Component c) {
   boolean menuBarPopup = false;
   if (c instanceof JPopupMenu) {
     JPopupMenu pm = (JPopupMenu) c;
     if (pm.getInvoker() != null) {
       menuBarPopup = (pm.getInvoker().getParent() instanceof JMenuBar);
     }
   }
   return menuBarPopup;
 }
Example #2
0
 /**
  * Returns the popup menu which is at the root of the menu system for this popup menu.
  *
  * @return the topmost grandparent <code>JPopupMenu</code>
  */
 JPopupMenu getRootPopupMenu() {
   JPopupMenu mp = this;
   while ((mp != null)
       && (mp.isPopupMenu() != true)
       && (mp.getInvoker() != null)
       && (mp.getInvoker().getParent() != null)
       && (mp.getInvoker().getParent() instanceof JPopupMenu)) {
     mp = (JPopupMenu) mp.getInvoker().getParent();
   }
   return mp;
 }