예제 #1
0
    public void actionPerformed(ActionEvent e) {
      JTextField tf = getTextField();
      final String text = tf.getText();
      final int caretIndex = tf.getCaretPosition();
      String pre = text.substring(0, caretIndex);
      java.util.List<TreeNode> nodes = null; // m_root.search(pre);
      // Collections.sort(nodes);
      if (nodes.isEmpty()) {
        return;
      }

      JPopupMenu jp = new JPopupMenu("options");

      JMenuItem lastItem = null;
      for (TreeNode node : nodes) {
        String nodeName = node.toString();
        String insertion = nodeName.substring(leaf(pre, ".").length());
        lastItem = createInsertAction(nodeName, caretIndex, insertion);
        jp.add(lastItem);
      }
      if (nodes.size() == 0) {
        return;
      }
      if (nodes.size() == 1) {
        lastItem.getAction().actionPerformed(null);
      } else {
        Point pos = tf.getCaret().getMagicCaretPosition();
        pos = pos != null ? pos : new Point(2, 2);
        jp.show(tf, pos.x, pos.y);
      }
    }
    /** Opens the SubMenu */
    public void menuKeyTyped(MenuKeyEvent e) {
      if (!crossMenuMnemonic) {
        JPopupMenu pm = getActivePopupMenu();
        if (pm != null && pm != menuItem.getParent()) {
          return;
        }
      }

      int key = menuItem.getMnemonic();
      if (key == 0) return;
      MenuElement path[] = e.getPath();
      if (lower((char) key) == lower(e.getKeyChar())) {
        JPopupMenu popupMenu = ((JMenu) menuItem).getPopupMenu();
        MenuElement sub[] = popupMenu.getSubElements();
        if (sub.length > 0) {
          MenuSelectionManager manager = e.getMenuSelectionManager();
          MenuElement newPath[] = new MenuElement[path.length + 2];
          System.arraycopy(path, 0, newPath, 0, path.length);
          newPath[path.length] = popupMenu;
          newPath[path.length + 1] = sub[0];
          manager.setSelectedPath(newPath);
        }
        e.consume();
      }
    }
예제 #3
0
  private void creerMenuContextuel() {
    menuActions = new JPopupMenu();
    menuPlacer = new JMenu("Placer");
    menuActions.add(menuPlacer);
    itemRetirer = new JMenuItem("Retirer");
    menuActions.add(itemRetirer);
    itemPlacerNord = new JMenuItem("vers Nord");
    menuPlacer.add(itemPlacerNord);
    itemPlacerEst = new JMenuItem("vers Est");
    menuPlacer.add(itemPlacerEst);
    itemPlacerSud = new JMenuItem("vers Sud");
    menuPlacer.add(itemPlacerSud);
    itemPlacerOuest = new JMenuItem("vers Ouest");
    menuPlacer.add(itemPlacerOuest);

    menuOrienter = new JMenu("Orienter");
    menuActions.add(menuOrienter);
    itemOrienterNord = new JMenuItem("vers Nord");
    menuOrienter.add(itemOrienterNord);
    itemOrienterEst = new JMenuItem("vers Est");
    menuOrienter.add(itemOrienterEst);
    itemOrienterSud = new JMenuItem("vers Sud");
    menuOrienter.add(itemOrienterSud);
    itemOrienterOuest = new JMenuItem("vers Ouest");
    menuOrienter.add(itemOrienterOuest);
  }
  private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) {
    JPopupMenu jp = new JPopupMenu();

    JMenuItem mi = new JMenuItem("Help"); // No i18n
    JPanel panel = new JPanel();

    String msgTxt =
        "<html>Drops redundant events/alerts. <br>The suppressed/dropped Events/alerts will not <br>be added to the database. <br>You can choose to suppress all events/alerts <br>or only those that occur after a <br>certain period of time. <br>Refer Admin Guide for details.</html>"; // No i18n

    /*JTextArea ep = new JTextArea();
    ep.setColumns(20);
    ep.setLineWrap(true);
    ep.setRows(10);
    ep.setBackground(new java.awt.Color(200, 200, 200));
    ep.setWrapStyleWord(true);*/
    JLabel ep = new JLabel();
    ep.setSize(300, 200);
    ep.setText(msgTxt);
    panel.add(ep);

    mi.setLayout(new BorderLayout());
    mi.setPreferredSize(panel.getPreferredSize());
    mi.setFocusPainted(false);
    mi.add(panel, BorderLayout.CENTER);
    jp.setLayout(new BorderLayout());
    jp.add(mi, BorderLayout.CENTER);
    jp.show(helpButton, -60, -60);
  }
예제 #5
0
  /** Shows popup with forward history entries */
  private void showForwardHistory(MouseEvent e) {

    JPopupMenu forwardMenu = new JPopupMenu("Forward History");

    if (historyModel == null) {
      return;
    }

    Locale locale = ((JHelp) getControl()).getModel().getHelpSet().getLocale();
    Enumeration items = historyModel.getForwardHistory().elements();
    JMenuItem mi = null;
    int index = historyModel.getIndex() + 1;
    // while(items.hasMoreElements()){
    for (int i = 0; items.hasMoreElements(); i++) {
      HelpModelEvent item = (HelpModelEvent) items.nextElement();
      if (item != null) {
        String title = item.getHistoryName();
        if (title == null) {
          title = HelpUtilities.getString(locale, "history.unknownTitle");
        }
        mi = new JMenuItem(title);
        // mi.setToolTipText(item.getURL().getPath());
        mi.addActionListener(new HistoryActionListener(i + index));
        forwardMenu.add(mi);
      }
    }
    // if(e.isPopupTrigger())
    forwardMenu.show(e.getComponent(), e.getX(), e.getY());
  }
예제 #6
0
  /**
   * A chat room was selected. Opens the chat room in the chat window.
   *
   * @param e the <tt>MouseEvent</tt> instance containing details of the event that has just
   *     occurred.
   */
  public void mousePressed(MouseEvent e) {
    // Select the object under the right button click.
    if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0
        || (e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
        || (e.isControlDown() && !e.isMetaDown())) {
      int ix = this.chatRoomList.rowAtPoint(e.getPoint());

      if (ix != -1) {
        this.chatRoomList.setRowSelectionInterval(ix, ix);
      }
    }

    Object o = this.chatRoomsTableModel.getValueAt(this.chatRoomList.getSelectedRow());

    Point selectedCellPoint = e.getPoint();

    SwingUtilities.convertPointToScreen(selectedCellPoint, chatRoomList);

    if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
      JPopupMenu rightButtonMenu;

      if (o instanceof ChatRoomWrapper)
        rightButtonMenu = new ChatRoomRightButtonMenu((ChatRoomWrapper) o);
      else return;

      rightButtonMenu.setInvoker(this);
      rightButtonMenu.setLocation(selectedCellPoint);
      rightButtonMenu.setVisible(true);
    }
  }
    public void showContextMenu(final ContextMenuParams params) {
      final JPopupMenu popupMenu = new JPopupMenu();
      if (!params.getLinkText().isEmpty()) {
        popupMenu.add(
            createMenuItem(
                "Open link in new window",
                new Runnable() {
                  public void run() {
                    String linkURL = params.getLinkURL();
                    System.out.println("linkURL = " + linkURL);
                  }
                }));
      }

      final Browser browser = params.getBrowser();
      popupMenu.add(
          createMenuItem(
              "Reload",
              new Runnable() {
                public void run() {
                  browser.reload();
                }
              }));

      final Point location = params.getLocation();
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              popupMenu.show(component, location.x, location.y);
            }
          });
    }
예제 #8
0
파일: Tray.java 프로젝트: Tyf0n/musique
  private void createPopup(JPopupMenu popup) {
    ActionListener al =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand().trim();
            if (cmd.equalsIgnoreCase("play")) {
              player.play();
            } else if (cmd.equalsIgnoreCase("pause")) {
              player.pause();
            } else if (cmd.equalsIgnoreCase("next")) {
              player.next();
            } else if (cmd.equalsIgnoreCase("previous")) {
              player.prev();
            } else if (cmd.equalsIgnoreCase("stop")) {
              player.stop();
            } else if (cmd.equalsIgnoreCase("quit")) {
              app.exit();
            }
          }
        };

    popup.add("   Play").addActionListener(al);
    popup.add("   Pause").addActionListener(al);
    popup.add("   Next").addActionListener(al);
    popup.add("   Stop").addActionListener(al);
    popup.add("   Previous   ").addActionListener(al);
    popup.add("   Quit").addActionListener(al);
  }
예제 #9
0
  public static void main(String... args) throws Exception {
    Robot robot = new Robot();

    SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            popup = new JPopupMenu();
            popup.add(new JMenuItem("item"));
            popup.setVisible(true);
          }
        });

    robot.waitForIdle();

    if (!popup.isShowing()) {
      throw new RuntimeException("Where is my popup ?");
    }

    SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            popup.setVisible(false);
            popup.removeAll();
            popup.setVisible(true);
          }
        });

    robot.waitForIdle();

    if (popup.isShowing()) {
      throw new RuntimeException("Empty popup is shown");
    }

    popup.setVisible(false);
  }
예제 #10
0
  @Override
  public JPopupMenu getComponentPopupMenu() {
    if (popupMenu == null) {
      popupMenu = new JPopupMenu(Messages.CHART_COLON);
      timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU);
      timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU));
      popupMenu.add(timeRangeMenu);
      menuRBs = new JRadioButtonMenuItem[rangeNames.length];
      ButtonGroup rbGroup = new ButtonGroup();
      for (int i = 0; i < rangeNames.length; i++) {
        menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]);
        rbGroup.add(menuRBs[i]);
        menuRBs[i].addActionListener(this);
        if (viewRange == rangeValues[i]) {
          menuRBs[i].setSelected(true);
        }
        timeRangeMenu.add(menuRBs[i]);
      }

      popupMenu.addSeparator();

      saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM);
      saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM));
      saveAsMI.addActionListener(this);
      popupMenu.add(saveAsMI);
    }
    return popupMenu;
  }
  public void eventDispatched(AWTEvent event) {
    if (!isAssertTrigger(event)) {
      return;
    }

    MouseEvent mouse = (MouseEvent) event;

    GuiComponent guiComponent = factory.find(mouse);

    if (guiComponent == null) {
      return;
    }

    assertContext.setGuiComponent(guiComponent);
    assertContext.setPoint(mouse.getPoint());

    JPopupMenu menu = dialogManager.newPopupMenu();

    for (Iterator iterator = actionManager.actions(); iterator.hasNext(); ) {
      AbstractAssert assertAction = (AbstractAssert) iterator.next();
      String actionId = (String) assertAction.getValue(AbstractAssert.ACTION_ID);

      ActionViewUtil.connectActionTo(assertAction, menu.add(actionId));
      assertAction.update();

      if (!guiComponent.isFindable()
          && AbstractAssert.COMPONENT_ASSERT == assertAction.getAssertType()) {
        assertAction.setEnabled(false);
      }
    }

    menu.setBorder(BorderFactory.createLineBorder(Color.blue, 5));
    menu.show(guiComponent.getSwingComponent(), mouse.getX(), mouse.getY());
  }
예제 #12
0
  private void showSliderMenu() {
    Point location = new Point(getX(), getY() + getHeight());

    SwingUtilities.convertPointToScreen(location, InputVolumeControlButton.this.getParent());

    if (isFullScreen()) {
      location.setLocation(
          location.getX(),
          location.getY() - sliderMenu.getPreferredSize().getHeight() - getHeight());
    }

    sliderMenu.setLocation(location);

    sliderMenu.addPopupMenuListener(
        new PopupMenuListener() {
          public void popupMenuWillBecomeVisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = true;
          }

          public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = false;
          }

          public void popupMenuCanceled(PopupMenuEvent ev) {}
        });

    sliderMenu.setVisible(!sliderMenu.isVisible());
  }
예제 #13
0
    public ManagerPopupMenu() {
      jPopupMenu = new JPopupMenu();
      Font font = new Font("Verdana", Font.PLAIN, 12);

      JMenuItem jFormProviderOrderItem = new JMenuItem("Отменить заказ");
      jFormProviderOrderItem.setFont(font);
      jFormProviderOrderItem.addActionListener(e -> ClientWindow.this.cancelClientOrder());
      jPopupMenu.add(jFormProviderOrderItem);
      jPopupMenu.addSeparator();
      JMenuItem jPay25OrderItem = new JMenuItem("Оплатить часть заказа");
      jPay25OrderItem.addActionListener(
          e ->
              ClientWindow.this.pay25Order(
                  ((DefaultMutableTreeNode) e.getSource()).getUserObject().toString()));
      jPay25OrderItem.setFont(font);
      jPopupMenu.add(jPay25OrderItem);
      jPopupMenu.addSeparator();
      JMenuItem jPayFullOrderItem = new JMenuItem("Оплатить весь заказ");
      jPayFullOrderItem.addActionListener(
          e ->
              ClientWindow.this.payFullOrder(
                  ((DefaultMutableTreeNode) e.getSource()).getUserObject().toString()));
      jPayFullOrderItem.setFont(font);
      jPopupMenu.add(jPayFullOrderItem);
    }
예제 #14
0
  @NotNull
  private JPopupMenu createMenu(final Node config) {
    JPopupMenu menu = new JPopupMenu();
    final JCheckBoxMenuItem showRpmItem = new JCheckBoxMenuItem("Show RPM");
    final JCheckBoxMenuItem showCommandsItem = new JCheckBoxMenuItem("Show Commands");
    showRpmItem.setSelected(showRpmPanel);
    ActionListener showCheckboxListener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            showRpmPanel = showRpmItem.isSelected();
            showMessagesPanel = showCommandsItem.isSelected();
            config.setProperty(SHOW_RPM, showRpmPanel);
            config.setProperty(SHOW_MESSAGES, showMessagesPanel);
            applyShowFlags();
            // todo: this is not needed if we show/hide RPM panel. TODO: split into two different
            // listeners
            middleSplitPanel.setDividerLocation(0.5);
          }
        };
    showRpmItem.addActionListener(showCheckboxListener);
    showCommandsItem.addActionListener(showCheckboxListener);

    menu.add(showRpmItem);
    showCommandsItem.setSelected(showMessagesPanel);
    menu.add(showCommandsItem);
    menu.add(new JPopupMenu.Separator());
    menu.add(new JPopupMenu("Reset Config"));
    return menu;
  }
  public static void main(String[] args) {
    final JPopupMenu menu = new JPopupMenu();
    menu.setLayout(new GridLayout(0, 3, 5, 5));

    final MenuedButton button = new MenuedButton("Icons", menu);

    for (int i = 0; i < 9; i++) {
      // replace "print.gif" with your own image
      final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") );
      label.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              button.getMainButton().setIcon(label.getIcon());
              menu.setVisible(false);
            }
          });
      menu.add(label);
    }

    JFrame frame = new JFrame("Button Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH);
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
예제 #16
0
  @NotNull
  private JPanel createRightTopPanel(Node config) {
    JPanel rightUpperPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));

    final JPopupMenu selectorMenu = new JPopupMenu();
    selectorMenu.add(
        new SizeSelectorPanel(
            new SizeSelectorPanel.SizeSelectorListener() {
              @Override
              public void onSelected(int row, int column) {
                System.out.println("new size " + row + "/" + column);
                applySize(row, column);
              }
            }));

    JButton selector = new JButton("O");
    selector.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Component c = (Component) e.getSource();
            selectorMenu.show(c, -1, c.getHeight());
          }
        });
    rightUpperPanel.add(selector);

    JButton menuButton = new PopupMenuButton("#", createMenu(config));
    rightUpperPanel.add(menuButton);
    return rightUpperPanel;
  }
예제 #17
0
파일: Tray.java 프로젝트: Tyf0n/musique
    private void showJPopupMenu(MouseEvent e) {
      try {
        if (e.isPopupTrigger() && menu != null) {
          if (window == null) {

            if (isWindows) {
              window = new JDialog((Frame) null);
              ((JDialog) window).setUndecorated(true);
            } else {
              window = new JWindow((Frame) null);
            }
            window.setAlwaysOnTop(true);
            Dimension size = menu.getPreferredSize();

            Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
            if (e.getY() > centerPoint.getY()) window.setLocation(e.getX(), e.getY() - size.height);
            else window.setLocation(e.getX(), e.getY());

            window.setVisible(true);

            menu.show(((RootPaneContainer) window).getContentPane(), 0, 0);

            // popup works only for focused windows
            window.toFront();
          }
        }
      } catch (Exception ignored) {
      }
    }
예제 #18
0
  @Override
  public void mouseMoved(MouseEvent e) {
    final MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, getParent());
    final boolean insideRec = getBounds().contains(event.getPoint());
    boolean buttonsNotPressed =
        (e.getModifiersEx()
                & (InputEvent.BUTTON1_DOWN_MASK
                    | InputEvent.BUTTON2_DOWN_MASK
                    | InputEvent.BUTTON3_DOWN_MASK))
            == 0;
    if (!myPopupIsShowing && insideRec && buttonsNotPressed) {
      showPopup(null, false);
    } else if (myPopupIsShowing && !insideRec) {
      final Component over =
          SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
      JPopupMenu popup = myUnderPopup.isShowing() ? myUnderPopup : myAbovePopup;
      if (over != null && popup.isShowing()) {
        final Rectangle rec = new Rectangle(popup.getLocationOnScreen(), popup.getSize());
        int delta = 15;
        rec.x -= delta;
        rec.width += delta * 2;
        rec.y -= delta;
        rec.height += delta * 2;

        final Point eventPoint = e.getPoint();
        SwingUtilities.convertPointToScreen(eventPoint, e.getComponent());

        if (rec.contains(eventPoint)) {
          return;
        }
      }

      closePopup();
    }
  }
예제 #19
0
파일: JImage.java 프로젝트: RussTedrake/lcm
  void initControls() {
    JMenuItem jmi;

    jmi = new JMenuItem("JImage Menu");
    jmi.setEnabled(false);
    popupMenu.add(jmi);

    jmi = new JMenuItem("Fit");
    jmi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fit = true;
            repaint();
          }
        });
    popupMenu.add(jmi);

    JMenu scaleMenu = new JMenu("Set Scale");
    popupMenu.add(scaleMenu);
    int scales[] = new int[] {25, 50, 100, 200, 400, 800};

    for (int i = 0; i < scales.length; i++) {
      jmi = new JMenuItem(scales[i] + " %");
      jmi.addActionListener(new ScaleAction(scales[i]));
      scaleMenu.add(jmi);
    }

    MyListener l = new MyListener();
    addMouseMotionListener(l);
    addMouseListener(l);
    addMouseWheelListener(l);
    addKeyListener(l);
  }
  /** Display the forwards window history in a menu. */
  private void onShowForwardHistory() {

    UIScrollableMenu hist =
        new UIScrollableMenu(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.forwardHistory"),
            0); //$NON-NLS-1$

    Vector views = history.getForwardHistory();
    int currentIndex = history.getCurrentPosition();

    int count = views.size();
    if (count == 0) return;

    JMenuItem item = null;
    for (int i = 0; i < count; i++) {
      View view = (View) views.elementAt(i);
      item = new JMenuItem(view.getLabel());

      final View fview = view;
      final int fi = (currentIndex + 1) + i;
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              if (history.goToHistoryItem(fi)) oParent.addViewToDesktop(fview, fview.getLabel());
            }
          });

      hist.add(item);
    }

    JPopupMenu pop = hist.getPopupMenu();
    pop.pack();

    Point loc = pbShowForwardHistory.getLocation();
    Dimension size = pbShowForwardHistory.getSize();
    Dimension popsize = hist.getPreferredSize();
    Point finalP = SwingUtilities.convertPoint(tbrToolBar.getParent(), loc, oParent.getDesktop());

    int x = 0;
    int y = 0;
    if (oManager.getLeftToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x + size.width;
      y = finalP.y;
    } else if (oManager.getRightToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x - popsize.width;
      y = finalP.y;
    } else if (oManager.getTopToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x;
      y = finalP.y + size.width;
    } else if (oManager.getBottomToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x;
      y = finalP.y - popsize.height;
    }

    hist.setPopupMenuVisible(true);
    pop.show(oParent.getDesktop(), x, y);
  }
 public void showPopupAbove(Point loc, GraphControllerPopupListener graphControllerPopupListener) {
   if (_popUp.isVisible()) {
     _popUp.setVisible(false);
   } else {
     _popUp.show(_desktopPane, 0, 0);
     _popUp.setLocation(loc.x, loc.y - _popUp.getHeight());
   }
   _currentGraphControllerPopupListener = graphControllerPopupListener;
 }
예제 #22
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;
 }
예제 #23
0
 /**
  * constructor
  *
  * @param values list of values, String[]
  */
 public MPopButton(String[] values) {
   this();
   for (int i = 0; i < values.length; i++) {
     JMenuItem item = popup.add(values[i]);
     item.addActionListener(popActionListener);
     popup.add(item);
     m_aListValues.add(values[i]);
   }
   setDefaultText();
 } // MPopButton()
예제 #24
0
 /**
  * constructor
  *
  * @param values list of values, ArrayList
  */
 public MPopButton(ArrayList values) {
   this();
   for (int i = 0; i < values.size(); i++) {
     JMenuItem item = popup.add((String) values.get(i));
     item.addActionListener(popActionListener);
     popup.add(item);
   }
   m_aListValues = values;
   setDefaultText();
 } // MPopButton()
예제 #25
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;
 }
예제 #26
0
 private void openPopup(Point p, Integer frame, String path) {
   JPopupMenu menu = new JPopupMenu();
   JMenuItem item = new JMenuItem(String.format("Analyze in Wireshark", frame));
   item.addActionListener(
       e -> {
         String wireshark = Environment.WIRESHARK_EXEC.getPath();
         openInWireshark(wireshark, frame, path);
       });
   menu.add(item);
   menu.show(this.table, p.x, p.y);
 }
  public void createPopupMenu() {
    menu = new JPopupMenu();
    for (int i = filenames.size() - 2, j = 0; i >= 0; i--, j++) {
      menu.add((String) filenames.elementAt(i));
      JMenuItem mi = (JMenuItem) menu.getComponent(j);
      mi.setFont(new Font("Arial", Font.PLAIN, 11));
      mi.addActionListener(this);
    }

    menu.pack();
    // setPopupLocation(200, 200);
  }
예제 #28
0
 @Override
 public void invokePopup(Component comp, int x, int y) {
   // Single right click
   ActionManager actionManager = ActionManager.getInstance();
   ActionGroup actionGroup =
       (ActionGroup) actionManager.getAction(ImageEditorActions.GROUP_POPUP);
   ActionPopupMenu menu =
       actionManager.createActionPopupMenu(ImageEditorActions.ACTION_PLACE, actionGroup);
   JPopupMenu popupMenu = menu.getComponent();
   popupMenu.pack();
   popupMenu.show(comp, x, y);
 }
예제 #29
0
 /**
  * Determines whether or not the given mouse event is actually a popup trigger.
  *
  * @param aPoint the <em>corrected</em> mouse position, where the popup is to be shown, cannot be
  *     <code>null</code>;
  * @param aEvent the mouse event that could be a popup trigger, cannot be <code>null</code>.
  */
 private boolean handlePopupTrigger(final Point aPoint, final MouseEvent aEvent) {
   final boolean popupTrigger = isCursorPopupTrigger(aEvent);
   if (popupTrigger) {
     JPopupMenu contextMenu = createCursorPopup(aPoint, aEvent.getLocationOnScreen());
     if (contextMenu != null) {
       contextMenu.show(aEvent.getComponent(), aEvent.getX(), aEvent.getY());
       // Mark the event as consumed...
       aEvent.consume();
     }
   }
   return popupTrigger;
 }
  /** Removes the menu represented by the node */
  private void removeVisualMenu(RADMenuItemComponent comp) {
    Object o = getBeanInstance();
    Object m = comp.getBeanInstance();
    Object dto = getDesignTimeMenus(getFormManager()).getDesignTime(o);
    Object dtm = getDesignTimeMenus(getFormManager()).getDesignTime(m);

    switch (getMenuItemType()) {
      case T_MENUBAR:
        ((MenuBar) o).remove((Menu) m);
        ((JMenuBar) dto).remove((JMenu) dtm);
        ((JMenuBar) dto).validate();
        break;
      case T_MENU:
        if (comp.getMenuItemType() == T_SEPARATOR) {
          ((Menu) o).remove(subComponents.indexOf(comp));
          ((JMenu) dto).remove(subComponents.indexOf(comp));
        } else {
          ((Menu) o).remove((MenuItem) m);
          ((JMenu) dto).remove((JMenuItem) dtm);
        }
        break;
      case T_POPUPMENU:
        if (comp.getMenuItemType() == T_SEPARATOR) {
          ((Menu) o).remove(subComponents.indexOf(comp));
          // PENDING - dont know how to get reference to JPopupMenu.Separator
          // so it is not supported by getDesignTimeMenu () !!
          // ((JPopupMenu)dto).remove((JPopupMenu.Separator)dtm);
        } else {
          ((Menu) o).remove((MenuItem) m);
          ((JPopupMenu) dto).remove((JMenuItem) dtm);
        }
        break;
      case T_JMENUBAR:
        ((JMenuBar) o).remove((JMenu) m);
        ((JMenuBar) o).validate();
        break;
      case T_JMENU:
        if (comp.getMenuItemType() == T_JSEPARATOR) {
          ((JMenu) o).remove(subComponents.indexOf(comp));
        } else {
          ((JMenu) o).remove((JMenuItem) m);
        }
        break;
      case T_JPOPUPMENU:
        if (comp.getMenuItemType() == T_JSEPARATOR) {
          // XXX(-tdt) ((JPopupMenu)o).remove((JPopupMenu.Separator)m);
          ((JPopupMenu) o).remove(subComponents.indexOf(comp));
        } else {
          ((JPopupMenu) o).remove((JMenuItem) m);
        }
        break;
    }
  }