Package javax.swing

Examples of javax.swing.MenuElement


   
    public Object pushMenu(ComponentOperator oper, PathChooser chooser) {
        Timeout maxTime = oper.getTimeouts().create("ComponentOperator.WaitComponentTimeout");
        JMenuBar bar = (JMenuBar)(oper.getSource());
        activateMenu(bar);
        MenuElement menuObject;
        maxTime.start();
        while(!chooser.checkPathComponent(0, (menuObject = getSelectedElement(bar)))) {
            pressKey(KeyEvent.VK_RIGHT, 0);
            releaseKey(KeyEvent.VK_RIGHT, 0);
            if(maxTime.expired()) {
                throw(new TimeoutExpiredException("AppleMenuDriver: can not find an appropriate menu!"));
            }
        }
        for(int depth = 1; depth < chooser.getDepth(); depth++) {
            // TODO - wait for menu item
            int elementIndex = getDesiredElementIndex(menuObject, chooser, depth);
            if(elementIndex == -1) {
                throw(new JemmyException("Unable to find menu (menuitem): " + ((DescriptablePathChooser)chooser).getDescription()));
            }
            for(int i = ((depth == 1) ? 0 : 1); i<=elementIndex; i++) {
                pressKey(KeyEvent.VK_DOWN, 0);
                releaseKey(KeyEvent.VK_DOWN, 0);
            }
            if(depth == chooser.getDepth() - 1) {
                pressKey(KeyEvent.VK_ENTER, 0);
                releaseKey(KeyEvent.VK_ENTER, 0);
                return(null);
            } else {
                pressKey(KeyEvent.VK_RIGHT, 0);
                releaseKey(KeyEvent.VK_RIGHT, 0);
                menuObject = menuObject.getSubElements()[0].getSubElements()[elementIndex];
            }
        }
        return menuObject;
    }
View Full Code Here


                Object o = e.getSource();
                if (o instanceof MenuSelectionManager) {
                    MenuSelectionManager manager = (MenuSelectionManager) o;
                    MenuElement[] elements = manager.getSelectedPath();
                    if (elements.length != 0) {
                        MenuElement element = elements[elements.length - 1];
                        event.reset();
                        event.object = element;
                        event.readType = ReadType.MENU;
                        ComponentScreenReader reader = readers.instance(event);
                        if(TextToSpeechOptions.isScreenReading()) {
View Full Code Here

        control.setComponentPopupMenu(popupMenu);
    }

    private void loadAction(DefaultMutableTreeNode node, MenuElement menu) {
        Object userObject = null;
        MenuElement menuElement = menu;
        if (menu.getSubElements().length > 0 &&
                menu.getSubElements()[0] instanceof JPopupMenu) {
            menuElement = menu.getSubElements()[0];
        }
        for (MenuElement item : menuElement.getSubElements()) {
            if (item instanceof JMenuItem) {
                JMenuItem menuItem = ((JMenuItem)item);
                if (menuItem.getAction() != null) {
                    Action action = menuItem.getAction();
                    userObject = action;
View Full Code Here

     *
     */
    static JMenuItem findMenuItem(Container container, String[] path) {
        if (path.length == 0) return null;

        MenuElement currentItem = findMenuBar(container);
        if (currentItem == null) return null;

        for (int i = 0; i < path.length; i++) {
            currentItem = findMenuItem(currentItem, path[i]);
            if (currentItem == null) return null;
View Full Code Here

  }

  public MenuElement [] getPath()
  {
    MenuSelectionManager m = MenuSelectionManager.defaultManager();
    MenuElement oldPath[] = m.getSelectedPath();
    MenuElement newPath[];
    int i = oldPath.length;
    if (i == 0)
      return new MenuElement [0];
    Component parent = menuItem.getParent();
    if (oldPath [i - 1].getComponent() == parent)
View Full Code Here

    int i, j;
    for (i = 0, j = path.length; i < j; i++)
    {
      for (int k = 0; k <= i; k++)
        System.out.print("  ");
      MenuElement me = path [i];
      if (me instanceof JMenuItem)
        System.out.println(((JMenuItem) me).getText() + ", ");
      else if (me == null)
        System.out.println("NULL , ");
      else
View Full Code Here

      {
        MenuSelectionManager.defaultManager().processMouseEvent(e);
      }
      else
      {
        MenuElement path[] = manager.getSelectedPath();
        if (path.length > 1)
        {
          MenuElement newPath[] = new MenuElement [path.length - 1];
          int i, c;
          for (i = 0, c = path.length - 1; i < c; i++)
            newPath [i] = path [i];
          manager.setSelectedPath(newPath);
        }
View Full Code Here

    }

    public void menuDragMouseDragged(MenuDragMouseEvent e)
    {
      MenuSelectionManager manager = e.getMenuSelectionManager();
      MenuElement path[] = e.getPath();
      manager.setSelectedPath(path);
    }
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.