Java 类javax.swing.JPopupMenu 实例源码

项目:cuttlefish    文件:EditEdgeMenu.java   
public EditEdgeMenu(Edge edge, BrowsableNetwork network, MouseEvent event) {
    this.edge = edge;
    this.event = event;
    this.network = network;

    // Menu items
    mLabel = new JMenuItem("Label: " + edge.getLabel());
    mWeight = new JMenuItem("Set weight...");
    mWidth = new JMenuItem("Set width...");
    mColor = new JMenuItem("Set color...");
    mDelete = new JMenuItem("Delete");

    // Add items to popup menu
    menu = new JPopupMenu();
    menu.add(mLabel);
    menu.add(new JSeparator());
    menu.add(mWeight);
    menu.add(mWidth);
    menu.add(mColor);
    menu.add(new JSeparator());
    menu.add(mDelete);

    addListeners();
}
项目:rapidminer    文件:MetaDataDeclarationEditor.java   
@Override
public JPopupMenu createPopupMenu() {
    JPopupMenu popUp = super.createPopupMenu();
    // JMenuItem deselect = new JMenuItem(new ResourceAction("wizard.deselect_all") {
    //
    // @Override
    // public void actionPerformed(ActionEvent e) {
    // // TODO Auto-generated method stub
    //
    // }
    // });

    // TODO implement selectAll and deselectALL Columns MenuItems here
    // popUp.add(deselect);
    return popUp;
}
项目:VASSAL-src    文件:ConfigureTree.java   
protected JPopupMenu buildPopupMenu(final Configurable target) {
  final JPopupMenu popup = new JPopupMenu();
  final ArrayList<Action> l = new ArrayList<Action>();
  l.add(buildEditAction(target));
  l.add(buildEditPiecesAction(target));
  addActionGroup(popup, l);
  l.add(buildTranslateAction(target));
  addActionGroup(popup, l);
  l.add(buildHelpAction(target));
  addActionGroup(popup, l);
  l.add(buildDeleteAction(target));
  l.add(buildCutAction(target));
  l.add(buildCopyAction(target));
  l.add(buildPasteAction(target));
  l.add(buildMoveAction(target));
  addActionGroup(popup, l);
  for (Action a : buildAddActionsFor(target)) {
    addAction(popup, a);
  }
  if (hasChild(target, PieceSlot.class) || hasChild(target, CardSlot.class)) {
    addAction(popup, buildMassPieceLoaderAction(target));
  }
  addAction(popup, buildImportAction(target));
  return popup;
}
项目:incubator-netbeans    文件:TableView.java   
/**
 * Find relevant actions and call the factory to create a popup.
 */
private JPopupMenu createPopup(Point p) {
    int[] selRows = table.getSelectedRows();
    Node[] arr = new Node[selRows.length];
    for (int i = 0; i < selRows.length; i++) {
        arr[i] = getNodeFromRow(selRows[i]);
    }
    if (arr.length == 0) {
        // hack to show something even when no rows are selected
        arr = new Node[] { manager.getRootContext() };
    }

    p = SwingUtilities.convertPoint(this, p, table);
    int column = table.columnAtPoint(p);
    int row = table.rowAtPoint(p);
    return popupFactory.createPopupMenu(row, column, arr, table);
}
项目:xdman    文件:XDMMainWindow.java   
void createContextMenu() {
    ctxPopup = new JPopupMenu();
    addMenuItem("CTX_OPEN", ctxPopup);
    addMenuItem("CTX_OPEN_FOLDER", ctxPopup);
    addMenuItem("CTX_SAVE_AS", ctxPopup);
    addMenuItem("CTX_SHOW_PRG", ctxPopup);
    addMenuItem("PAUSE", ctxPopup);
    addMenuItem("RESUME", ctxPopup);
    addMenuItem("RESTART", ctxPopup);
    addMenuItem("DELETE", ctxPopup);
    addMenuItem("REFRESH_LINK", ctxPopup);
    addMenuItem("CTX_ASM", ctxPopup);
    addMenuItem("CTX_ADD_Q", ctxPopup);
    addMenuItem("CTX_DEL_Q", ctxPopup);

    // ctxPopup.add(createSortMenu());
    addMenuItem("CTX_COPY_URL", ctxPopup);
    addMenuItem("CTX_COPY_FILE", ctxPopup);
    addMenuItem("PROPERTIES", ctxPopup);
    ctxPopup.setInvoker(table);
}
项目:incubator-netbeans    文件:OutlineView.java   
@Override
protected void showPopup (MouseEvent e) {
    int selRow = outline.rowAtPoint(e.getPoint());

    if (selRow != -1) {
        if (! outline.getSelectionModel().isSelectedIndex(selRow)) {
            outline.getSelectionModel().clearSelection();
            outline.getSelectionModel().setSelectionInterval(selRow, selRow);
        }
    } else {
        outline.getSelectionModel().clearSelection();
    }
    Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), OutlineView.this);
    if (isPopupAllowed()) {
        JPopupMenu pop = createPopup(p);
        OutlineView.this.showPopup(p.x, p.y, pop);
        e.consume();
    }
}
项目:incubator-netbeans    文件:ProfilerToolbarDropdownAction.java   
public Component getToolbarPresenter() {
    if (toolbarPresenter == null) {
        // gets the real action registered in the menu from layer
        Action a = Actions.forID("Profile", "org.netbeans.modules.profiler.actions.AttachMainProject"); // NOI18N
        final Action attachProjectAction = a != null ? a : /* XXX should be impossible */AttachAction.getInstance();

        // gets the real action registered in the menu from layer
        a = Actions.forID("Profile", "org.netbeans.modules.profiler.actions.AttachAction"); // NOI18N
        final Action attachProcessAction = a != null ? a : /* XXX should be impossible */AttachAction.getInstance();

        JPopupMenu dropdownPopup = new JPopupMenu();
        dropdownPopup.add(createDropdownItem(defaultAction));
        dropdownPopup.add(createDropdownItem(attachProjectAction));
        dropdownPopup.addSeparator();
        dropdownPopup.add(createDropdownItem(attachProcessAction));

        JButton button = DropDownButtonFactory.createDropDownButton(new ImageIcon(
                new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB)), dropdownPopup);
        Actions.connect(button, defaultAction);

        toolbarPresenter = button;
    }

    return toolbarPresenter;
}
项目:incubator-netbeans    文件:ButtonPopupSwitcher.java   
private void doSelect(JComponent owner) {
    invokingComponent = owner;
    invokingComponent.addMouseListener(this);
    invokingComponent.addMouseMotionListener(this);
    pTable.addMouseListener(this);
    pTable.addMouseMotionListener(this);
    pTable.getSelectionModel().addListSelectionListener( this );

    displayer.getModel().addComplexListDataListener( this );

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);

    popup = new JPopupMenu();
    popup.setBorderPainted( false );
    popup.setBorder( BorderFactory.createEmptyBorder() );
    popup.add( pTable );
    popup.pack();
    int locationX = x - (int) pTable.getPreferredSize().getWidth();
    int locationY = y + 1;
    popup.setLocation( locationX, locationY );
    popup.setInvoker( invokingComponent );
    popup.addPopupMenuListener( this );
    popup.setVisible( true );
    shown = true;
    invocationTime = System.currentTimeMillis();
}
项目:AgentWorkbench    文件:JPanelOwnMTP.java   
@Override
public void actionPerformed(ActionEvent ae) {

    Object trigger = ae.getSource();
    if (trigger==this.getJRadioButtonMtpAutoConfig()) {
        // --- Switch to MTP-auto configuration -------
        this.refreshView();
    } else if (trigger==this.getJRadioButtonMtpIP()) {
        // --- Switch to MTP-IP usage -----------------         
        this.refreshView();

    } else if (trigger==this.getJButtonIPedit()) {
        NetworkAddresses netAddresses = new NetworkAddresses();
        JPopupMenu popUp = netAddresses.getJPopupMenu4NetworkAddresses(this);
        popUp.show(this.getJTextFieldIPAddress(), 0, this.getJTextFieldIPAddress().getHeight());

    } else if (trigger instanceof JMenuItem) {
        // --- Trigger from JPopoupMenue for the IP-Addresses ---
        JMenuItem menuItem = (JMenuItem) trigger;
        this.getJTextFieldIPAddress().setText(menuItem.getActionCommand());

    } else if (trigger==this.getJButtonSetPortMTPDefault()) {
        // --- Set default MTP port -------------------
        this.getJTextFieldDefaultPortMTP().setText("7778");
    }
}
项目:jaer    文件:AePlayerAdvancedControlsPanel.java   
/**
     * Creates new form AePlayerAdvancedControlsPanel.
     *
     * @param viewer the viewer to control.
     */
    public AePlayerAdvancedControlsPanel(AEViewer viewer) {
        this.markOutLabel = new JLabel("]");
        this.markInLabel = new JLabel("[");
        markInLabel.setToolTipText("IN marker");
        markOutLabel.setToolTipText("OUT marker");
        this.aeViewer = viewer;
        this.aePlayer = viewer.getAePlayer();
        initComponents();
        setAePlayer(viewer.getAePlayer()); // TODO double set needed because aePlayer is needed in initComponents and we still need to do more component binding in setAePlayer
        moreControlsPanel.setVisible(false);
        markerPopupMenu=new JPopupMenu("Markers");
        markerPopupMenu.add(aePlayer.markInAction);
        markerPopupMenu.add(aePlayer.markOutAction);
        markerPopupMenu.add(aePlayer.clearMarksAction);
        playerSlider.setComponentPopupMenu(markerPopupMenu);
//        playerSlider.setExtent(100);
        repeatPlaybackButton.setSelected(aePlayer.isRepeat());
    }
项目:marathonv5    文件:RMenuItem.java   
private String buildMenuElementArray(JMenuItem leaf) {
    Vector<JMenuItem> elements = new Vector<JMenuItem>();

    elements.insertElementAt(leaf, 0);
    Component current = leaf.getParent();

    while (current != null) {
        if (current instanceof JPopupMenu) {
            JPopupMenu pop = (JPopupMenu) current;
            current = pop.getInvoker();
        } else if (current instanceof JMenu) {
            JMenu menu = (JMenu) current;
            elements.insertElementAt(menu, 0);
            current = menu.getParent();
        } else if (current instanceof JMenuBar) {
            break;
        } else {
            current = current.getParent();
        }
    }
    mainMenu = elements.get(0);
    JMenuItem parent = null;
    StringBuilder sb = new StringBuilder();
    RComponentFactory finder = new RComponentFactory(omapConfig);
    for (JMenuItem jMenuItem : elements) {
        RComponent rComponent = finder.findRComponent(jMenuItem, null, recorder);
        recorder.recordMenuItem(rComponent);
        String text = JMenuItemJavaElement.getText(JMenuItemJavaElement.getItemText(jMenuItem), jMenuItem,
                parent == null ? new Component[0] : ((JMenu) parent).getMenuComponents());
        parent = jMenuItem;
        sb.append(text).append(">>");
    }
    sb.setLength(sb.length() - 2);
    return sb.toString();
}
项目:VASSAL-src    文件:MenuScroller.java   
/**
 * Constructs a <code>MenuScroller</code> that scrolls a popup menu with the
 * specified number of items to display in the scrolling region, the
 * specified scrolling interval, and the specified numbers of items fixed at
 * the top and bottom of the popup menu.
 *
 * @param menu the popup menu
 * @param scrollCount the number of items to display in the scrolling portion
 * @param interval the scroll interval, in milliseconds
 * @param topFixedCount the number of items to fix at the top.  May be 0
 * @param bottomFixedCount the number of items to fix at the bottom.  May be 0
 * @throws IllegalArgumentException if scrollCount or interval is 0 or
 * negative or if topFixedCount or bottomFixedCount is negative
 */
public MenuScroller(JPopupMenu menu, int scrollCount, int interval,
        int topFixedCount, int bottomFixedCount) {
  if (scrollCount <= 0 || interval <= 0) {
    throw new IllegalArgumentException("scrollCount and interval must be greater than 0");
  }
  if (topFixedCount < 0 || bottomFixedCount < 0) {
    throw new IllegalArgumentException("topFixedCount and bottomFixedCount cannot be negative");
  }

  upItem = new MenuScrollItem(MenuIcon.UP, -1);
  downItem = new MenuScrollItem(MenuIcon.DOWN, +1);
  setScrollCount(scrollCount);
  setInterval(interval);
  setTopFixedCount(topFixedCount);
  setBottomFixedCount(bottomFixedCount);

  this.menu = menu;
  menu.addPopupMenuListener(menuListener);
}
项目:VASSAL-src    文件:HtmlChart.java   
public void mousePressed(MouseEvent event) {
  if (event.isMetaDown()) {
    final JPopupMenu popup = new JPopupMenu();
    final JMenuItem item = new JMenuItem("Return to default page");

    item.addActionListener(new ActionListener() {
      // Return to default page
      public void actionPerformed(ActionEvent e) {
        setFile(fileName);
      }
    });

    popup.add(item);
    if (event.getComponent().isShowing()) {
      popup.show(event.getComponent(), event.getX(), event.getY());
    }
  }
}
项目:scorekeeperfrontend    文件:EntryPanel.java   
public void actionPerformed(ActionEvent e)
{
    JPopupMenu menu = new JPopupMenu();

    // nothing seems to work for HTML based MenuItem, its part of the HTML editor kit or something else without an interface
    //UIDefaults overrides = new UIDefaults();
    //overrides.put("MenuItem[MouseOver].backgroundPainter", OtherPainterHere);
    //menu.putClientProperty("Nimbus.Overrides", overrides);
    //menu.putClientProperty("Nimbus.Overrides.InheritDefaults", false);

    for (DecoratedCar car : carVector)
    {
        if (car.getCarId().equals(selectedCar.getCarId()) || car.isInRunOrder())
            continue;
        menu.add(new MovePaymentAction(car));
    }
    Component c = (Component)e.getSource();
    menu.show(c, 5, c.getHeight()-5);
}
项目:jmt    文件:ExactTable.java   
protected JPopupMenu makeMouseMenu() {
    JPopupMenu menu = new JPopupMenu();
    menu.add(COPY_ACTION);
    menu.add(CUT_ACTION);
    menu.add(PASTE_ACTION);
    menu.add(CLEAR_ACTION);
    menu.add(FILL_ACTION);
    return menu;
}
项目:TuLiPA-frames    文件:XMLTreeListener.java   
public XMLTreeListener(TreeViewPanel panel)
{
    super(panel);
    popupMenu = new JPopupMenu();
       JMenuItem expandAllAttributesMenuItem = new JMenuItem("Expand all attributes");
       expandAllAttributesMenuItem.addActionListener(this);
       JMenuItem collapseAllAttributesMenuItem = new JMenuItem("Collapse all attributes");
       collapseAllAttributesMenuItem.addActionListener(this);
       JMenuItem expandAllNodesMenuItem = new JMenuItem("Expand all nodes");
       expandAllNodesMenuItem.addActionListener(this);
       JMenuItem collapseAllNodesMenuItem = new JMenuItem("Collapse all nodes");
       collapseAllNodesMenuItem.addActionListener(this);      
       JMenuItem increaseVerticalNodeDistanceMenuItem = new JMenuItem("Increase vertical node distance");
       increaseVerticalNodeDistanceMenuItem.addActionListener(this);
       JMenuItem decreaseVerticalNodeDistanceMenuItem = new JMenuItem("Decrease vertical node distance");
       decreaseVerticalNodeDistanceMenuItem.addActionListener(this);
       JMenuItem increaseHorizontalNodeDistanceMenuItem = new JMenuItem("Increase horizontal node distance");
       increaseHorizontalNodeDistanceMenuItem.addActionListener(this);
       JMenuItem decreaseHorizontalNodeDistanceMenuItem = new JMenuItem("Decrease horizontal node distance");
       decreaseHorizontalNodeDistanceMenuItem.addActionListener(this);  
       JMenuItem toggleEdgyLinesMenuItem = new JMenuItem("Toggle edgy lines");
       toggleEdgyLinesMenuItem.addActionListener(this); 
       JMenuItem savePaneToFileMenuItem = new JMenuItem("Save tree display ...");
       savePaneToFileMenuItem.addActionListener(this);
       popupMenu.add(expandAllAttributesMenuItem);
       popupMenu.add(collapseAllAttributesMenuItem);
       popupMenu.addSeparator();
       popupMenu.add(expandAllNodesMenuItem);
       popupMenu.add(collapseAllNodesMenuItem);
       popupMenu.addSeparator();
       popupMenu.add(increaseVerticalNodeDistanceMenuItem);
       popupMenu.add(decreaseVerticalNodeDistanceMenuItem);
       popupMenu.addSeparator();
       popupMenu.add(increaseHorizontalNodeDistanceMenuItem);
       popupMenu.add(decreaseHorizontalNodeDistanceMenuItem);
       popupMenu.addSeparator();
       popupMenu.add(toggleEdgyLinesMenuItem);
       popupMenu.addSeparator();
       popupMenu.add(savePaneToFileMenuItem);  
}
项目:jmt    文件:JWatVariableInputTable.java   
protected JPopupMenu makeMouseMenu() {
    JPopupMenu menu = new JPopupMenu();
    menu.add(deleteClass);
    menu.add(new JSeparator());
    menu.add(deselectAll);
    return menu;
}
项目:openjdk-jdk10    文件:JPopupMenuOperator.java   
/**
 * Maps {@code JPopupMenu.removePopupMenuListener(PopupMenuListener)}
 * through queue
 */
public void removePopupMenuListener(final PopupMenuListener popupMenuListener) {
    runMapping(new MapVoidAction("removePopupMenuListener") {
        @Override
        public void map() {
            ((JPopupMenu) getSource()).removePopupMenuListener(popupMenuListener);
        }
    });
}
项目:VASSAL-src    文件:ServerAddressBook.java   
public void showPopup(JComponent source) {
  final JPopupMenu popup = new JPopupMenu();

  for (Enumeration<?> e = addressBook.elements(); e.hasMoreElements();) {
    final AddressBookEntry entry = (AddressBookEntry) e.nextElement();
    final JMenuItem item = new JMenuItem(entry.toString());
    final AbstractAction action = new MenuAction(entry);
    item.setAction(action);
    item.setIcon(entry.getIcon(IconFamily.SMALL));
    popup.add(item);
  }
  popup.show(source, 0, 0);
}
项目:rapidminer    文件:ToggleAction.java   
public ToggleDropDownButton createDropDownToggleButton(final JPopupMenu popupMenu) {
    ToggleJToggleDropDownButton button = new ToggleJToggleDropDownButton(this) {

        private static final long serialVersionUID = 619422148555974973L;

        @Override
        protected JPopupMenu getPopupMenu() {
            return popupMenu;
        }
    };
    listeners.add(button);
    return button;
}
项目:incubator-netbeans    文件:SelectionList.java   
/**
 * Show popup menu from actions provided by node at given index (if any).
 *
 * @param rowIndex
 * @param location
 */
private void showPopupMenuAt(int rowIndex, Point location) {
    ListNode node = getModel().getElementAt(rowIndex);
    Action[] actions = node.getPopupActions();

    if (null == actions || actions.length == 0) {
        return;
    }
    JPopupMenu popup = Utilities.actionsToPopup(actions, this);
    popup.show(this, location.x, location.y);
}
项目:openjdk-jdk10    文件:JPopupMenuOperator.java   
/**
 * Maps {@code JPopupMenu.setPopupSize(int, int)} through queue
 */
public void setPopupSize(final int i, final int i1) {
    runMapping(new MapVoidAction("setPopupSize") {
        @Override
        public void map() {
            ((JPopupMenu) getSource()).setPopupSize(i, i1);
        }
    });
}
项目:incubator-netbeans    文件:MenuEditLayer.java   
public static boolean isMenuRelatedContainer(RADComponent comp) {
    if(comp == null) return false;
    Class clas = comp.getBeanClass();
    if(clas == null) return false;
    if(JMenu.class.isAssignableFrom(clas)) return true;
    if(JPopupMenu.class.isAssignableFrom(clas)) return true;
    return false;
}
项目:openjdk-jdk10    文件:TestPopupMenu.java   
public TestPopupMenu() throws Exception {
    Robot robot = new Robot();
    robot.setAutoDelay(200);
    try {
        SwingUtilities.invokeAndWait(() -> {
            try {
                createAndShowUI();
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        });
        blockTillDisplayed(label);
        robot.waitForIdle();
        robot.mouseMove(p.x + d.width/2, p.y + d.height/2);
        robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
        robot.waitForIdle();
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_U);
        robot.keyRelease(KeyEvent.VK_U);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.waitForIdle();
        JPopupMenu popup = label.getComponentPopupMenu();
        if (popup != null && popup.isVisible()) {
            throw new RuntimeException("Popup is visible in wrong internal frame");
        }
    } finally {
        SwingUtilities.invokeAndWait(()->frame.dispose());
    }
}
项目:Pogamut3    文件:SimpleBasicWidget.java   
@Override
final public JPopupMenu getPopupMenu(Widget arg0, Point arg1) {
    JPopupMenu menu = new JPopupMenu("Popup menu");

    // create action list
    List<AbstractMenuAction> actionList = createMenuActions();

    for (AbstractMenuAction action : actionList) {
        JMenuItem item = new JMenuItem(action.getDescription());
        item.addActionListener(action);
        menu.add(item);
    }

    return menu;
}
项目:incubator-netbeans    文件:ExtKit.java   
public void actionPerformed(ActionEvent evt, JTextComponent target) {
    if (target != null) {
        if (debugPopupMenu) {
            /*DEBUG*/System.err.println("POPUP CREATION START <<<<<"); // NOI18N
        }
        JPopupMenu pm = buildPopupMenu(target);
        if (debugPopupMenu) {
            /*DEBUG*/System.err.println("POPUP CREATION END >>>>>"); // NOI18N
        }
        Utilities.getEditorUI(target).setPopupMenu(pm);
    }
}
项目:openjdk-jdk10    文件:JPopupMenuOperator.java   
/**
 * Maps {@code JPopupMenu.setLabel(String)} through queue
 */
public void setLabel(final String string) {
    runMapping(new MapVoidAction("setLabel") {
        @Override
        public void map() {
            ((JPopupMenu) getSource()).setLabel(string);
        }
    });
}
项目:incubator-netbeans    文件:DropdownButton.java   
private void addAction(JPopupMenu popup, Action action) {
    if (action == null) {
        popup.addSeparator();
    } else {
        Class cls = (Class)action.getValue(KEY_CLASS);
        if (Boolean.class.equals(cls)) {
            Boolean boolvalue = (Boolean)action.getValue(KEY_BOOLVALUE);
            JCheckBoxMenuItem item = new JCheckBoxMenuItem(action);
            item.setSelected(boolvalue);
            popup.add(item);
        } else {
            popup.add(action);
        }
    }
}
项目:rapidminer    文件:FileTable.java   
private void initPopupMenu() {
    this.panePopup = this.fileList.getPanePopup();

    this.headerPopup = new JPopupMenu();

    String col = "";
    this.en = this.columnNames.elements();
    while (this.en.hasMoreElements()) {
        col = this.en.nextElement().toString();
        this.menuItem = new JCheckBoxMenuItem(col);
        this.menuItem.setSelected(true);
        this.menuItem.addActionListener(this.hal);
        this.headerPopup.add(this.menuItem);
    }
}
项目:incubator-netbeans    文件:JPopupMenuUtils.java   
/** Mysterious calls to pack(), invalidate() and validate() ;-) */
private static void refreshPopup(JPopupMenu popup) {
    popup.pack();
    popup.invalidate();

    Component c = popup.getParent();

    if (c != null) {
        c.validate();
    }
}
项目:incubator-netbeans    文件:DropdownButton.java   
public void displayPopup() {
    JPopupMenu menu = new JPopupMenu();
    populatePopup(menu);
    if (menu.getComponentCount() > 0) {
        Dimension size = menu.getPreferredSize();
        size.width = Math.max(size.width, getWidth());
        menu.setPreferredSize(size);
        menu.show(this, 0, getHeight());
    }
}
项目:cuttlefish    文件:EditVertexMenu.java   
public EditVertexMenu(Vertex v, BrowsableNetwork network, MouseEvent e) {

        this.vertex = v;
        this.event = e;
        this.network = network;

        // Menu items
        mID = new JMenuItem("ID: " + v.getId());
        mID.setEnabled(false);
        mLabel = new JMenuItem("Label: " + v.getLabel());
        mSize = new JMenuItem("Size: " + v.getSize());
        mFillColor = new JMenuItem("Set fill color...");
        mBorderColor = new JMenuItem("Set border color...");
        mBorderWidth = new JMenuItem("Set border width...");
        mShape = new JMenuItem("Set shape...");
        mDelete = new JMenuItem("Delete");

        // Add items to popup
        menu = new JPopupMenu();
        menu.add(mID);
        menu.add(mLabel);
        menu.add(mSize);
        menu.add(new JSeparator());

        menu.add(mFillColor);
        menu.add(mBorderColor);
        menu.add(mBorderWidth);
        menu.add(mShape);
        menu.add(new JSeparator());

        menu.add(mDelete);

        addListeners();
    }
项目:JavaGraph    文件:LabelTree.java   
/**
 * Creates a popup menu, consisting of show and hide actions.
 */
private JPopupMenu createPopupMenu() {
    JPopupMenu result = new JPopupMenu();
    addActionItems(result);
    addFilterItems(result);
    addShowHideItems(result);
    return result;
}
项目:incubator-netbeans    文件:NodePopupFactory.java   
void addNoFilterItem(ETable et, JPopupMenu popup) {
    if (showQuickFilter && et.getQuickFilterColumn() != -1) {
        String s = NbBundle.getMessage(NodePopupFactory.class, "LBL_QuickFilter");
        JMenu menu = new JMenu(s);
        JMenuItem noFilterItem = et.getQuickFilterNoFilterItem(et.getQuickFilterFormatStrings()[6]);
        menu.add(noFilterItem);
        popup.add(menu);
    }
}
项目:incubator-netbeans    文件:OutlineView.java   
@Override
public void run() {
    Point p = getPositionForPopup ();
    if (p == null) {
        return ;
    }
    if (isPopupAllowed()) {
        JPopupMenu pop = createPopup(p);
        showPopup(p.x, p.y, pop);
    }
}
项目:incubator-netbeans    文件:OutlineView.java   
@Override
public JPopupMenu createPopupMenu(int row, int column, Node[] selectedNodes, Component component) {
    if (component instanceof ETable) {
        ETable et = (ETable)component;
        int modelRowIndex = et.convertColumnIndexToModel(column);
        setShowQuickFilter(modelRowIndex != 0);
    }
    return super.createPopupMenu(row, column, selectedNodes, component);
}
项目:rapidminer    文件:DropDownButton.java   
public static DropDownButton makeDropDownButton(Action mainAction, boolean showButton, Action... actions) {
    final JPopupMenu menu = new JPopupMenu();
    for (Action action : actions) {
        menu.add(action);
    }
    return new DropDownButton(mainAction, showButton) {

        private static final long serialVersionUID = -7359018188605409766L;

        @Override
        protected JPopupMenu getPopupMenu() {
            return menu;
        }
    };
}
项目:incubator-netbeans    文件:StatusLineComponent.java   
private void showMenu(MouseEvent e) {
    JPopupMenu popup = new JPopupMenu();
    popup.add(new ProgressListAction(NbBundle.getMessage(StatusLineComponent.class, "StatusLineComponent.ShowProcessList"))); 
    popup.add(new ViewAction());
    popup.add(new CancelAction(true));
    popup.show((Component)e.getSource(), e.getX(), e.getY());
}
项目:incubator-netbeans    文件:AbstractQuickSearchComboBar.java   
/**
 * Show and select menu at a given path. Used to restore a menu after click.
 */
private void showMenuPath(MenuElement[] selectedPath) {
    if (selectedPath != null && selectedPath.length > 1) {
        if (selectedPath[0] instanceof JPopupMenu) {
            ((JPopupMenu) selectedPath[0]).setVisible(true);
            MenuSelectionManager.defaultManager().setSelectedPath(
                    selectedPath);
        }
    }
}
项目:incubator-netbeans    文件:MainProjectActionWithHistory.java   
@Override
public Component getToolbarPresenter() {

        JPopupMenu menu = new JPopupMenu();
        JButton button = DropDownButtonFactory.createDropDownButton(
                new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB)), menu);
        final JMenuItem item = new JMenuItem(org.openide.awt.Actions.cutAmpersand((String) getValue("menuText")));
        item.setEnabled(isEnabled());

        addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                String propName = evt.getPropertyName();
                if ("enabled".equals(propName)) {
                    item.setEnabled((Boolean) evt.getNewValue());
                } else if ("menuText".equals(propName)) {
                    item.setText(org.openide.awt.Actions.cutAmpersand((String) evt.getNewValue()));
                }
            }
        });

        menu.add(item);
        item.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                MainProjectActionWithHistory.this.actionPerformed(e);
            }
        });

        org.openide.awt.Actions.connect(button, this);
        menu.addPopupMenuListener(this);
        return button;

}