當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuSelectionManager.clearSelectedPath方法代碼示例

本文整理匯總了Java中javax.swing.MenuSelectionManager.clearSelectedPath方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuSelectionManager.clearSelectedPath方法的具體用法?Java MenuSelectionManager.clearSelectedPath怎麽用?Java MenuSelectionManager.clearSelectedPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.MenuSelectionManager的用法示例。


在下文中一共展示了MenuSelectionManager.clearSelectedPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: altPressed

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
void altPressed(KeyEvent ev) {
    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    MenuElement[] path = msm.getSelectedPath();
    if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
        msm.clearSelectedPath();
        menuCanceledOnPress = true;
        ev.consume();
    } else if(path.length > 0) { // We are in ComboBox
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        ev.consume();
    } else {
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        JMenuBar mbar = root != null ? root.getJMenuBar() : null;
        if(mbar == null && winAncestor instanceof JFrame) {
            mbar = ((JFrame)winAncestor).getJMenuBar();
        }
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;
        if(menu != null) {
            ev.consume();
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:WindowsRootPaneUI.java

示例2: hide

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * This method hides drop down list of items
 */
public void hide()
{
  MenuSelectionManager menuSelectionManager =
    MenuSelectionManager.defaultManager();
  javax.swing.MenuElement[] menuElements =
    menuSelectionManager.getSelectedPath();
  for (int i = 0; i < menuElements.length; i++)
    {
      if (menuElements[i] == this)
        {
          menuSelectionManager.clearSelectedPath();
          break;
        }
    }
  comboBox.repaint();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:20,代碼來源:BasicComboPopup.java

示例3: mousePressed

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * Handles mouse pressed events from the event queue.
 *
 * @param ev the mouse pressed event
 */
private void mousePressed(MouseEvent ev)
{
  // Autoclose all menus managed by the MenuSelectionManager.
  MenuSelectionManager m = MenuSelectionManager.defaultManager();
  Component target = ev.getComponent();
  if (target instanceof Container)
    target = ((Container) target).findComponentAt(ev.getPoint());
  if (m.getSelectedPath().length > 0
      && ! m.isComponentPartOfCurrentMenu(target)
      && (((JComponent)target).getClientProperty(DONT_CANCEL_POPUP) == null
      || !((JComponent)target).getClientProperty(DONT_CANCEL_POPUP).equals(Boolean.TRUE)))
    {
      m.clearSelectedPath();
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:21,代碼來源:BasicLookAndFeel.java

示例4: hide

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
@Override
public void hide() {
	MenuSelectionManager manager = MenuSelectionManager.defaultManager();
	MenuElement[] selection = manager.getSelectedPath();
	for (MenuElement element : selection) {
		if (element == this) {
			manager.clearSelectedPath();
			break;
		}
	}
	ComboBoxUI.this.isDown = false;
	this.comboBox.repaint();
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:14,代碼來源:ComboBoxUI.java

示例5: menuDragMouseReleased

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * Tbis method is invoked when mouse was dragged and released inside the
 * menu item.
 *
 * @param e
 *          The MenuDragMouseEvent
 */
public void menuDragMouseReleased(MenuDragMouseEvent e)
{
  MenuSelectionManager manager = e.getMenuSelectionManager();
  int x = e.getX();
  int y = e.getY();
  if (x >= 0 && x < menuItem.getWidth() && y >= 0
      && y < menuItem.getHeight())
    doClick(manager);
  else
    manager.clearSelectedPath();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:19,代碼來源:BasicMenuItemUI.java

示例6: cancel

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * Handles cancel requests (ESC key).
 */
private void cancel()
{
  // Fire popup menu cancelled event. Unfortunately the
  // firePopupMenuCancelled() is protected in JPopupMenu so we work
  // around this limitation by fetching the listeners and notifying them
  // directly.
  JPopupMenu lastPopup = (JPopupMenu) getLastPopup();
  EventListener[] ll = lastPopup.getListeners(PopupMenuListener.class);
  for (int i = 0; i < ll.length; i++)
    {
      PopupMenuEvent ev = new PopupMenuEvent(lastPopup);
      ((PopupMenuListener) ll[i]).popupMenuCanceled(ev);
    }

  // Close the last popup or the whole selection if there's only one
  // popup left.
  MenuSelectionManager msm = MenuSelectionManager.defaultManager();
  MenuElement path[] = msm.getSelectedPath();
  if(path.length > 4)
    {
      MenuElement newPath[] = new MenuElement[path.length - 2];
      System.arraycopy(path,0,newPath,0,path.length-2);
      MenuSelectionManager.defaultManager().setSelectedPath(newPath);
    }
  else
      msm.clearSelectedPath();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:31,代碼來源:BasicPopupMenuUI.java

示例7: doReturn

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * Handles ENTER key requests. This normally opens submenus on JMenu
 * items, or activates the menu item as if it's been clicked on it.
 */
private void doReturn()
{
  KeyboardFocusManager fmgr =
    KeyboardFocusManager.getCurrentKeyboardFocusManager();
  Component focusOwner = fmgr.getFocusOwner();
  if((focusOwner == null || (focusOwner instanceof JRootPane)))
    {
      MenuSelectionManager msm = MenuSelectionManager.defaultManager();
      MenuElement path[] = msm.getSelectedPath();
      MenuElement lastElement;
      if(path.length > 0)
        {
          lastElement = path[path.length - 1];
          if(lastElement instanceof JMenu)
            {
              MenuElement newPath[] = new MenuElement[path.length + 1];
              System.arraycopy(path,0,newPath,0,path.length);
              newPath[path.length] = ((JMenu) lastElement).getPopupMenu();
              msm.setSelectedPath(newPath);
            }
          else if(lastElement instanceof JMenuItem)
            {
              JMenuItem mi = (JMenuItem)lastElement;
              if (mi.getUI() instanceof BasicMenuItemUI)
                {
                  ((BasicMenuItemUI)mi.getUI()).doClick(msm);
                }
              else
                {
                  msm.clearSelectedPath();
                  mi.doClick(0);
                }
            }
        }
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:41,代碼來源:BasicPopupMenuUI.java

示例8: mousePressed

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
public void mousePressed(MouseEvent e)
{
  MenuSelectionManager manager = MenuSelectionManager.defaultManager();
  JMenu menu = (JMenu) menuItem;
  if (menu.isEnabled())
    {
      // Open up the menu immediately if it's a toplevel menu.
      // But not yet the popup, which might be opened delayed, see below.
      if (menu.isTopLevelMenu())
        {
          if (menu.isSelected())
            manager.clearSelectedPath();
          else
            {
              Container cnt = menu.getParent();
              if (cnt != null && cnt instanceof JMenuBar)
                {
                  MenuElement[] me = new MenuElement[2];
                  me[0] = (MenuElement) cnt;
                  me[1] = menu;
                  manager.setSelectedPath(me);
               }
            }
        }

      // Open the menu's popup. Either do that immediately if delay == 0,
      // or delayed when delay > 0.
      MenuElement[] selectedPath = manager.getSelectedPath();
      if (selectedPath.length > 0
          && selectedPath[selectedPath.length - 1] != menu.getPopupMenu())
        {
          if(menu.isTopLevelMenu() || menu.getDelay() == 0)
            {
              MenuElement[] newPath =
                new MenuElement[selectedPath.length + 1];
              System.arraycopy(selectedPath, 0, newPath, 0,
                               selectedPath.length);
              newPath[selectedPath.length] = menu.getPopupMenu();
              manager.setSelectedPath(newPath);
            }
          else
            {
              setupPostTimer(menu);
            }
        }

    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:49,代碼來源:BasicMenuUI.java

示例9: menuDragMouseDragged

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * This method is invoked when mouse is dragged over the menu item.
 *
 * @param e The MenuDragMouseEvent
 */
public void menuDragMouseDragged(MenuDragMouseEvent e)
{
  if (menuItem.isEnabled())
    {
      MenuSelectionManager manager = e.getMenuSelectionManager();
      MenuElement path[] = e.getPath();

      Point p = e.getPoint();
      if(p.x >= 0 && p.x < menuItem.getWidth()
          && p.y >= 0 && p.y < menuItem.getHeight())
        {
          JMenu menu = (JMenu) menuItem;
          MenuElement[] selectedPath = manager.getSelectedPath();
          if(! (selectedPath.length > 0
              && selectedPath[selectedPath.length-1]
                              == menu.getPopupMenu()))
            {
              if(menu.isTopLevelMenu() || menu.getDelay() == 0
                 || e.getID() == MouseEvent.MOUSE_DRAGGED)
                {
                  MenuElement[] newPath = new MenuElement[path.length + 1];
                  System.arraycopy(path, 0, newPath, 0, path.length);
                  newPath[path.length] = menu.getPopupMenu();
                  manager.setSelectedPath(newPath);
                }
              else
                {
                  manager.setSelectedPath(path);
                  setupPostTimer(menu);
                }
            }
        }
      else if (e.getID() == MouseEvent.MOUSE_RELEASED)
        {
          Component comp = manager.componentForPoint(e.getComponent(),
                                                     e.getPoint());
          if (comp == null)
            manager.clearSelectedPath();
        }
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:47,代碼來源:BasicMenuUI.java

示例10: popupMenuCanceled

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * This method is invoked when JPopupMenu is cancelled.
 *
 * @param event the PopupMenuEvent
 */
public void popupMenuCanceled(PopupMenuEvent event)
{
  MenuSelectionManager manager = MenuSelectionManager.defaultManager();
  manager.clearSelectedPath();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:11,代碼來源:BasicPopupMenuUI.java

示例11: doClick

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * Programatically clicks menu item.
 *
 * @param msm
 *          MenuSelectionManager for the menu hierarchy
 */
protected void doClick(MenuSelectionManager msm)
{
  menuItem.doClick(0);
  msm.clearSelectedPath();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:12,代碼來源:BasicMenuItemUI.java

示例12: componentResized

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * This method is invoked when top-level window is resized. This method
 * closes current menu hierarchy.
 *
 * @param e The ComponentEvent
 */
public void componentResized(ComponentEvent e)
{
  MenuSelectionManager manager = MenuSelectionManager.defaultManager();
  manager.clearSelectedPath();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:12,代碼來源:BasicPopupMenuUI.java

示例13: componentMoved

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * This method is invoked when top-level window is moved. This method
 * closes current menu hierarchy.
 *
 * @param e The ComponentEvent
 */
public void componentMoved(ComponentEvent e)
{
  MenuSelectionManager manager = MenuSelectionManager.defaultManager();
  manager.clearSelectedPath();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:12,代碼來源:BasicPopupMenuUI.java

示例14: componentShown

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * This method is invoked when top-level window is shown This method
 * does nothing by default.
 *
 * @param e The ComponentEvent
 */
public void componentShown(ComponentEvent e)
{
  MenuSelectionManager manager = MenuSelectionManager.defaultManager();
  manager.clearSelectedPath();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:12,代碼來源:BasicPopupMenuUI.java

示例15: componentHidden

import javax.swing.MenuSelectionManager; //導入方法依賴的package包/類
/**
 * This method is invoked when top-level window is hidden This method
 * closes current menu hierarchy.
 *
 * @param e The ComponentEvent
 */
public void componentHidden(ComponentEvent e)
{
  MenuSelectionManager manager = MenuSelectionManager.defaultManager();
  manager.clearSelectedPath();
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:12,代碼來源:BasicPopupMenuUI.java


注:本文中的javax.swing.MenuSelectionManager.clearSelectedPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。