Package javax.swing

Examples of javax.swing.MenuElement


      int len = path.length;

      if (len > 2 && path[len - 3] instanceof ScrollableMenu && path[len - 2] instanceof JPopupMenu) {

        ScrollableMenu menu = (ScrollableMenu) path[len - 3];
        MenuElement selected = path[len - 1];
        Component component = (direction == ScrollDirection.UP ? menu
            .getFirstVisibleAndEnabledComponent() : menu
            .getLastVisibleAndEnabledComponent());
        if (component == null || selected == component) {
          boolean enableScroll = (direction == ScrollDirection.UP ? menu.scrollUp.mEnableScroll
View Full Code Here


      @Override
      protected String[] executeInEDT() throws Throwable {
        MenuElement[] subElements = popupMenu.getSubElements();
        String[] result = new String[subElements.length];
        for (int i = 0; i < subElements.length; i++) {
          MenuElement subElement = checkNotNull(subElements[i]);
          result[i] = textOf(subElement);
        }
        return result;
      }
    });
View Full Code Here

  public void showPopup() {
    JMenu jmenu = (JMenu) getWidget();
    Container thisparent = jmenu.getParent();
    Stack<MenuElement> stack = MenuSelectionManager.defaultManager().getSelectionStack();
    while (!stack.isEmpty()) {
      MenuElement ele = stack.peek();
      if (ele instanceof JMenu) {
        JMenu jme = (JMenu) ele;
        Container parent = jme.getParent();
        jme.setPopupMenuVisible(false);
        jme.setSelected(false);
View Full Code Here

  public void hidePopup() {
    JMenu jmenu = (JMenu) getWidget();
    Stack<MenuElement> stack = MenuSelectionManager.defaultManager().getSelectionStack();
    while (!stack.isEmpty() && stack.peek() != jmenu) {
      MenuElement me = stack.pop();
      if (me instanceof JMenu) {
        JMenu jme = (JMenu) me;
        jme.setPopupMenuVisible(false);
        jme.setSelected(false);
      } else if (me instanceof JPopupMenu) {
View Full Code Here

  public void showPopup() {
    JPopupMenu jpm = (JPopupMenu) getWidget();
    Stack<MenuElement> stack = MenuSelectionManager.defaultManager().getSelectionStack();
    while (!stack.isEmpty()) {
      MenuElement ele = stack.peek();
      if (ele instanceof JMenu) {
        JMenu jme = (JMenu) ele;
        jme.setPopupMenuVisible(false);
        jme.setSelected(false);
      } else if (ele instanceof JPopupMenu) {
View Full Code Here

  public void hidePopup() {
    JPopupMenu jpm = (JPopupMenu) getWidget();
    Stack<MenuElement> stack = MenuSelectionManager.defaultManager().getSelectionStack();
    while (!stack.isEmpty() && stack.peek() != jpm) {
      MenuElement me = stack.pop();
      if (me instanceof JMenu) {
        JMenu jme = (JMenu) me;
        jme.setPopupMenuVisible(false);
        jme.setSelected(false);
      } else if (me instanceof JPopupMenu) {
View Full Code Here

        MenuElement[] selectedPath = MenuSelectionManager.defaultManager().getSelectedPath();
        if (Utilities.isEmptyArray(selectedPath)) {
            return new MenuElement[0];
        }

        MenuElement lastElement = selectedPath[selectedPath.length - 1];
        boolean pathContainsItem = lastElement == menuItem;
        if (!pathContainsItem && lastElement != menuItem.getParent()) {
            return new MenuElement[] {menuItem};
        }
        int resultLength = selectedPath.length + (pathContainsItem ? 0 : 1);
View Full Code Here

    }

    private static class MnemonicAction extends AbstractAction {
        public void actionPerformed(final ActionEvent e) {
            final JMenu menu = (JMenu)e.getSource();
            final MenuElement menuItem = getFirstMenuItem(menu);
            final MenuElement newSelection = (menuItem != null) ? menuItem : menu.getPopupMenu();
            final MenuElement[] path = Utilities.getMenuElementPath(newSelection);
            MenuSelectionManager.defaultManager().setSelectedPath(path);
        }
View Full Code Here

     * @return whether there are any icons at the moment
     */
    private static boolean hasIcons(MenuElement menuElement) {
        MenuElement[] elements = menuElement.getSubElements();
        for (int i = 0; i < elements.length; i++) {
            MenuElement element = elements[i];
            if (element instanceof JMenuItem && (((JMenuItem)element).getIcon() != null)) {
                return true;
            }
            if (element instanceof JPopupMenu) {
                return hasIcons(element);
View Full Code Here

     * Fill in icons (if there is no icon, put in an empty icon).
     */
    private static void fillInIcons(MenuElement menuElement) {
        MenuElement[] elements = menuElement.getSubElements();
        for (int i = 0; i < elements.length; i++) {
            MenuElement element = elements[i];
            if (element instanceof JMenuItem) {
                JMenuItem menu = (JMenuItem)element;
                if (menu.getIcon() == null) {
                    menu.setIcon(EmptyIcon.SMALL);
                }
View Full Code Here

TOP

Related Classes of javax.swing.MenuElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.