Java Code Examples for javax.swing.JPopupMenu

The following are top voted examples for showing how to use javax.swing.JPopupMenu. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: cuttlefish   File: EditEdgeMenu.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 2
Project: rapidminer   File: MetaDataDeclarationEditor.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 3
Project: VASSAL-src   File: ConfigureTree.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 4
Project: incubator-netbeans   File: TableView.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 5
Project: incubator-netbeans   File: ButtonPopupSwitcher.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 6
Project: AgentWorkbench   File: JPanelOwnMTP.java   Source Code and License 6 votes vote down vote up
@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");
	}
}
 
Example 7
Project: jaer   File: AePlayerAdvancedControlsPanel.java   Source Code and License 6 votes vote down vote up
/**
     * 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());
    }
 
Example 8
Project: marathonv5   File: RMenuItem.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 9
Project: VASSAL-src   File: MenuScroller.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 10
Project: VASSAL-src   File: HtmlChart.java   Source Code and License 6 votes vote down vote up
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());
    }
  }
}
 
Example 11
Project: scorekeeperfrontend   File: EntryPanel.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 12
Project: jmt   File: ExactTable.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 13
Project: TuLiPA-frames   File: XMLTreeListener.java   Source Code and License 5 votes vote down vote up
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);  
}
 
Example 14
Project: jmt   File: JWatVariableInputTable.java   Source Code and License 5 votes vote down vote up
protected JPopupMenu makeMouseMenu() {
	JPopupMenu menu = new JPopupMenu();
	menu.add(deleteClass);
	menu.add(new JSeparator());
	menu.add(deselectAll);
	return menu;
}
 
Example 15
Project: openjdk-jdk10   File: JPopupMenuOperator.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 16
Project: VASSAL-src   File: ServerAddressBook.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 17
Project: rapidminer   File: ToggleAction.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 18
Project: incubator-netbeans   File: SelectionList.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 19
Project: openjdk-jdk10   File: JPopupMenuOperator.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 20
Project: incubator-netbeans   File: MenuEditLayer.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 21
Project: openjdk-jdk10   File: TestPopupMenu.java   Source Code and License 5 votes vote down vote up
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());
    }
}
 
Example 22
Project: Pogamut3   File: SimpleBasicWidget.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 23
Project: incubator-netbeans   File: ExtKit.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 24
Project: openjdk-jdk10   File: JPopupMenuOperator.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 25
Project: incubator-netbeans   File: DropdownButton.java   Source Code and License 5 votes vote down vote up
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);
        }
    }
}
 
Example 26
Project: rapidminer   File: FileTable.java   Source Code and License 5 votes vote down vote up
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);
	}
}
 
Example 27
Project: incubator-netbeans   File: JPopupMenuUtils.java   Source Code and License 5 votes vote down vote up
/** 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();
    }
}
 
Example 28
Project: incubator-netbeans   File: DropdownButton.java   Source Code and License 5 votes vote down vote up
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());
    }
}
 
Example 29
Project: cuttlefish   File: EditVertexMenu.java   Source Code and License 5 votes vote down vote up
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();
	}
 
Example 30
Project: JavaGraph   File: LabelTree.java   Source Code and License 5 votes vote down vote up
/**
 * 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;
}
 
Example 31
Project: incubator-netbeans   File: NodePopupFactory.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 32
Project: xdman   File: XDMMainWindow.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 33
Project: incubator-netbeans   File: OutlineView.java   Source Code and License 5 votes vote down vote up
@Override
public void run() {
    Point p = getPositionForPopup ();
    if (p == null) {
        return ;
    }
    if (isPopupAllowed()) {
        JPopupMenu pop = createPopup(p);
        showPopup(p.x, p.y, pop);
    }
}
 
Example 34
Project: incubator-netbeans   File: OutlineView.java   Source Code and License 5 votes vote down vote up
@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();
    }
}
 
Example 35
Project: incubator-netbeans   File: OutlineView.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 36
Project: rapidminer   File: DropDownButton.java   Source Code and License 5 votes vote down vote up
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;
		}
	};
}
 
Example 37
Project: incubator-netbeans   File: StatusLineComponent.java   Source Code and License 5 votes vote down vote up
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());
}
 
Example 38
Project: incubator-netbeans   File: AbstractQuickSearchComboBar.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 39
Project: incubator-netbeans   File: MainProjectActionWithHistory.java   Source Code and License 5 votes vote down vote up
@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;
    
}
 
Example 40
Project: incubator-netbeans   File: MergeDialogComponent.java   Source Code and License 5 votes vote down vote up
/** Shows given popup on given coordinations and takes care about the
 *  situation when menu can exceed screen limits.
 *  Copied from org.netbeans.core.windows.frames.DefaultContainerImpl
 */
private static void showPopupMenu(JPopupMenu popup, Point p, Component comp) {
    SwingUtilities.convertPointToScreen(p, comp);
    Dimension popupSize = popup.getPreferredSize();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    
    if (p.x + popupSize.width > screenSize.width) {
        p.x = screenSize.width - popupSize.width;
    }
    if (p.y + popupSize.height > screenSize.height) {
        p.y = screenSize.height - popupSize.height;
    }
    SwingUtilities.convertPointFromScreen(p, comp);
    popup.show(comp, p.x, p.y);
}
 
Example 41
Project: incubator-netbeans   File: ProfilerToolbarDropdownAction.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 42
Project: incubator-netbeans   File: ActionMappings.java   Source Code and License 5 votes vote down vote up
public static void showAddPropertyPopupMenu(JButton btn, JTextComponent area, JTextField goalsField, @NullAllowed NbMavenProjectImpl project) {
    JPopupMenu menu = new JPopupMenu();
    menu.add(new SkipTestsAction(area));
    menu.add(new DebugMavenAction(area));
    menu.add(new EnvVarAction(area));
    menu.add(createJdkSubmenu(area));
    menu.add(createGlobalVarSubmenu(area));
    if (project != null) {
        menu.add(new PluginPropertyAction(area, goalsField, project));
    }
    menu.add(createFileSelectionSubmenu(area));
    menu.show(btn, btn.getSize().width, 0);
}
 
Example 43
Project: openjdk-jdk10   File: bug6495920.java   Source Code and License 5 votes vote down vote up
public bug6495920(JFrame frame) {
    JPopupMenu menu = new JPopupMenu() {
        public void setVisible(boolean visible) {
            super.setVisible(visible);
            throw new AssertionError(visible ? "show popup" : "hide popup");
        }
    };
    for (int i = 0; i < 10; i++) {
        menu.add(new JMenuItem(String.valueOf(i)));
    }
    this.panel = new JPanel();
    this.panel.setComponentPopupMenu(menu);
    frame.add(this.panel);
}
 
Example 44
Project: geomapapp   File: LineSegmentsObject.java   Source Code and License 5 votes vote down vote up
public LineSegmentsObject( XMap map, Digitizer dig ) {
	this.map = map;
	wrap = map.getWrap();
	this.dig = dig;
	points = new Vector();
	visible = true;
	currentSeg = null;
	name = null;
	selected = false;
	lineWidth = 1f;
	color = Color.black;
	when = 0L;
	currentPoint = -1;
	editShape = null;
	active = false;
	setColor( dig.options.color );
	setFill( dig.options.fill );
	setStroke( dig.options.stroke );
	lastColor = color;
	lastFill = Color.white;
	table = 0;
	
	rightClickMenu = new JPopupMenu("Popup");
	JMenuItem deleteItem = new JMenuItem("Delete Point");
	deleteItem.setToolTipText("Click to delete");
	deleteItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          dig.deletePtsBtn.doClick();
        }
      });
	rightClickMenu.add(deleteItem);
}
 
Example 45
Project: incubator-netbeans   File: AbstractContextMenuFactory.java   Source Code and License 5 votes vote down vote up
protected void populateMenu (JPopupMenu menu, Map context) {
        ActionProvider provider = getEngine().getActionProvider();
        String[] names = provider.getActionNames(ContainerProvider.CONTEXTMENU_CONTEXT);
        for (int i=0; i < names.length; i++) {
            JMenuItem item = getOrCreateMenuItem(
                provider.getActionType(names[i], ContainerProvider.CONTEXTMENU_CONTEXT));
            configureMenuItem (item, ContainerProvider.CONTEXTMENU_CONTEXT, names[i], provider, context);
            menu.add(item);
        }
//        getEngine().notifyMenuShown(ContainerProvider.CONTEXTMENU_CONTEXT, menu); //XXX listener should do this
//        addMapping (ContainerProvider.CONTEXTMENU_CONTEXT, menu, ContainerProvider.TYPE_MENU); //XXX handle popup
    }
 
Example 46
Project: incubator-netbeans   File: MenuChecker.java   Source Code and License 5 votes vote down vote up
/** Get Menu and tranfer it to ArrayList.
     * @param menu menu to be tranfered
     * @return tranfered menu  - !separator is ignored
     */
    public static ArrayList<NbMenuItem> getMenuArrayList(JMenu menu) {
//        System.out.println("getMenuArrayList: " + menu.getText());//DEBUG
//        menu.list();//DEBUG
        MenuElement[] elements = menu.getSubElements();
        ArrayList<NbMenuItem> list = new ArrayList<NbMenuItem>();

        for (int k = 0; k < elements.length; k++) {
//            System.out.print("getMenuArrayList: ");
//            ((JComponent) elements[k]).list(System.out);
            if (elements[k] instanceof JSeparator) {
                NbMenuItem separator = new NbMenuItem();
                separator.setSeparator(true);
                list.add(separator);
            } else {
                if (elements[k] instanceof JPopupMenu) {
                    list.addAll(getPopupMenuArrayList((JPopupMenu) elements[k]));
                } else {
                    if (elements[k] instanceof JMenuItem) {
                        NbMenuItem item = new NbMenuItem((JMenuItem) elements[k]);
                        item.setName(item.getName());
                        list.add(item);
                    } else {
                        System.out.println("getMenu unknown:" + elements[k].toString());
                    }
                }
            }

        }
        return list;
    }
 
Example 47
Project: incubator-netbeans   File: VCSStatusTable.java   Source Code and License 5 votes vote down vote up
private void showPopup(final MouseEvent e) {
    int row = table.rowAtPoint(e.getPoint());
    if (row != -1) {
        boolean makeRowSelected = true;
        int[] selectedrows = table.getSelectedRows();

        for (int i = 0; i < selectedrows.length; i++) {
            if (row == selectedrows[i]) {
                makeRowSelected = false;
                break;
            }
        }
        if (makeRowSelected) {
            table.getSelectionModel().setSelectionInterval(row, row);
        }
    }
    EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            // invoke later so the selection on the table will be set first
            if (table.isShowing()) {
                JPopupMenu menu = getPopup();
                if (menu != null) {
                    menu.show(table, e.getX(), e.getY());
                }
            }
        }
    });
}
 
Example 48
Project: rapidminer   File: LogViewer.java   Source Code and License 5 votes vote down vote up
/**
 * Creates the popup menu for the log text area.
 *
 * @return
 */
private JPopupMenu createPopupMenu() {
	JPopupMenu menu = new JPopupMenu();
	LogModel currentModel = getLogSelectionModel().getCurrentLogModel();

	// Studio log can be reset on each process start
	if (currentModel != null && currentModel.equals(RapidMinerGUI.getDefaultLogModel())) {
		menu.add(TOGGLE_CLEAR_ON_START_ACTION.createMenuItem());
	}

	// pull logs cannot be cleared
	if (currentModel != null && currentModel.getLogMode() != LogMode.PULL) {
		menu.add(CLEAR_MESSAGE_VIEWER_ACTION);
	} else {
		menu.add(CLOSE_ACTION);
	}

	menu.add(SAVE_LOGFILE_ACTION);
	menu.add(SEARCH_ACTION);

	// pull logs can be manually refreshed
	if (currentModel != null && currentModel.getLogMode() == LogMode.PULL) {
		menu.add(REFRESH_ACTION);
	}
	menu.addSeparator();

	menu.add(makeLogLevelMenu());

	return menu;
}
 
Example 49
Project: openjdk-jdk10   File: JPopupMenuOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JPopupMenu.setLightWeightPopupEnabled(boolean)} through queue
 */
public void setLightWeightPopupEnabled(final boolean b) {
    runMapping(new MapVoidAction("setLightWeightPopupEnabled") {
        @Override
        public void map() {
            ((JPopupMenu) getSource()).setLightWeightPopupEnabled(b);
        }
    });
}
 
Example 50
Project: incubator-netbeans   File: ResultWindow.java   Source Code and License 5 votes vote down vote up
/** Creates a new instance of ResultWindow */
@NbBundle.Messages({"TITLE_TEST_RESULTS=Test Results",
    "ACSN_TestResults=Test Results",
    "ACSD_TestResults=Displays information about passed and failed tests and output generated by them"})
public ResultWindow() {
    super();
    setFocusable(true);
    setLayout(new BorderLayout());

    setName(ID);
    setDisplayName(Bundle.TITLE_TEST_RESULTS());
    setIcon(ImageUtilities.loadImage( "org/netbeans/modules/gsf/testrunner/ui/resources/testResults.png", true));//NOI18N
     
    AccessibleContext accContext = getAccessibleContext();
    accContext.setAccessibleName(Bundle.ACSN_TestResults());
    accContext.setAccessibleDescription(Bundle.ACSD_TestResults());

    pop = new JPopupMenu();
    pop.add(new Close());
    pop.add(new CloseAll());
    pop.add(new CloseAllButCurrent());
    popL = new PopupListener();
    closeL = new CloseListener();

    tabPane = TabbedPaneFactory.createCloseButtonTabbedPane();
    tabPane.setMinimumSize(new Dimension(0, 0));
    tabPane.addMouseListener(popL);
    tabPane.addPropertyChangeListener(closeL);
    add(tabPane);
}
 
Example 51
Project: openjdk-jdk10   File: JPopupMenuOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JPopupMenu.getLabel()} through queue
 */
public String getLabel() {
    return (runMapping(new MapAction<String>("getLabel") {
        @Override
        public String map() {
            return ((JPopupMenu) getSource()).getLabel();
        }
    }));
}
 
Example 52
Project: geomapapp   File: CustomDB.java   Source Code and License 5 votes vote down vote up
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
//		GMA 1.4.8: Now check which combo box event is coming from
		if ( e.getSource() == box ) {

//			***** Changed by A.K.M. 6/23/06 *****
//			setPrototypeDisplayValue restricts the size of the box to a fixed 
//			length of eight characters
			box.setPrototypeDisplayValue("WWWWWWWW");
//			The popup listener adjusts the size of the popup to match the size 
//			of the text being displayed
			JComboBox tempBox = (JComboBox) e.getSource();
			Object comp = tempBox.getUI().getAccessibleChild(tempBox, 0);
			if (!(comp instanceof JPopupMenu)) {
				return;
			}
			JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0);
			Dimension size = scrollPane.getPreferredSize();
			UnknownDataSet tester1 = (UnknownDataSet)tempBox.getSelectedItem();
			CustomBRGTable.setReverseYAxis(false);
			CustomBRGTable.setIgnoreZeros(false);
//			6.5 is a hardcoded value that approximates the size of a 
//			character in pixels
//			TODO: Find exact size of text in pixels and adjust 
//			size.width accordingly
			if (tester1 != null) {
				if (maxDBNameLength < tester1.desc.name.length())	{
						maxDBNameLength = tester1.desc.name.length();
				}
				size.width = (int)(maxDBNameLength * 6.5);
				scrollPane.setPreferredSize(size);
			}
//			***** Changed by A.K.M. 6/23/06 *****
		}
	}
 
Example 53
Project: ramus   File: IDEFPanel.java   Source Code and License 5 votes vote down vote up
private JPopupMenu createTopPanelPopupMenu() {
    JPopupMenu menu = new JPopupMenu();
    menu.add(frame.findAction(MainFrame.MODEL_PROPETIES));
    menu.add(frame.findAction(MainFrame.DIAGRAM_PROPETIES));
    menu.add(frame.findAction(MainFrame.CREATE_LEVEL));
    return menu;
}
 
Example 54
Project: sbc-qsystem   File: JTreeComboBox.java   Source Code and License 5 votes vote down vote up
protected void initializePopup() {
    popup = new JPopupMenu();
    popup.setLayout(new BorderLayout());
    popup.setBorder(new EmptyBorder(0, 0, 0, 0));
    popup.addPopupMenuListener(this);
    popup.add(scroller);
    popup.pack();
}
 
Example 55
Project: incubator-netbeans   File: JComponentBuilders.java   Source Code and License 4 votes vote down vote up
protected void setupInstance(JPopupMenu instance) {
    super.setupInstance(instance);
    
    if (label != null) instance.setLabel(label);
    instance.setBorderPainted(paintBorder);
}
 
Example 56
Project: incubator-netbeans   File: FiltersMenuButton.java   Source Code and License 4 votes vote down vote up
void fillMenu(JPopupMenu popup, JMenu menu) {
    assert null != popup || null != menu;
    FilterRepository filterRep = FilterRepository.getInstance();
    NotificationFilter activeFilter = notificationManager.getActiveFilter();

    JRadioButtonMenuItem item = new JRadioButtonMenuItem(new CancelFilterAction());
    item.setSelected(NotificationFilter.EMPTY.equals(activeFilter));
    if (null == popup) {
        menu.add(item);
    } else {
        popup.add(item);
    }

    if (null == popup) {
        menu.addSeparator();
    } else {
        popup.addSeparator();
    }

    List<NotificationFilter> allFilters = filterRep.getAllFilters();
    for (NotificationFilter tf : allFilters) {
        item = new JRadioButtonMenuItem(new SetFilterAction(tf));
        item.setSelected(activeFilter.equals(tf));
        if (null == popup) {
            menu.add(item);
        } else {
            popup.add(item);
        }
    }
    if (allFilters.size() > 0) {
        if (null == popup) {
            menu.addSeparator();
        } else {
            popup.addSeparator();
        }
    }

    if (null == popup) {
        menu.add(new ManageFiltersAction());
    } else {
        popup.add(new ManageFiltersAction());
    }
}
 
Example 57
Project: incubator-netbeans   File: ResultView.java   Source Code and License 4 votes vote down vote up
public ResultView() {
    setLayout(contentCards = new CardLayout());

    setName("Search Results");                                      //NOI18N
    setDisplayName(NbBundle.getMessage(ResultView.class, "TITLE_SEARCH_RESULTS"));    //NOI18N
    
    initAccessibility();

    pop = new JPopupMenu();
    pop.add(new Close());
    pop.add(new CloseAll());
    pop.add(new CloseAllButCurrent());
    popL = new PopupListener();
    closeL = new CloseListener();
    
    emptyPanel = new JPanel();
    singlePanel = new JPanel();
    singlePanel.setLayout(new BoxLayout(singlePanel, BoxLayout.PAGE_AXIS));
    emptyPanel.setOpaque(true);
    tabs = TabbedPaneFactory.createCloseButtonTabbedPane();
    tabs.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            updateLookup();
        }
    });
    tabs.setMinimumSize(new Dimension(0, 0));
    tabs.addMouseListener(popL);
    tabs.addPropertyChangeListener(closeL);
    add(emptyPanel, CARD_NAME_EMPTY);
    add(tabs, CARD_NAME_TABS);
    add(singlePanel, CARD_NAME_SINGLE);
    if (isMacLaf) {
        emptyPanel.setBackground(macBackground);
        tabs.setBackground(macBackground);
        tabs.setOpaque(true);
        setBackground(macBackground);
        setOpaque(true);
    } else {
        emptyPanel.setBackground(
                UIManager.getColor("Tree.background"));         //NOI18N
    }
    contentCards.show(this, CARD_NAME_EMPTY);
    associateLookup(Lookups.proxy(lookupProvider));
}
 
Example 58
Project: QN-ACTR-Release   File: JWatVariableInputTable.java   Source Code and License 4 votes vote down vote up
public MouseHandler(JPopupMenu menu) {
	this.menu = menu;
}
 
Example 59
Project: rapidminer   File: AbstractChartPanel.java   Source Code and License 4 votes vote down vote up
/**
 * Returns the popup menu.
 * 
 * @return The popup menu.
 */

@Override
public JPopupMenu getPopupMenu() {
	return this.popup;
}
 
Example 60
Project: marathonv5   File: PopupMenuDemo.java   Source Code and License 4 votes vote down vote up
PopupListener(JPopupMenu popupMenu) {
    popup = popupMenu;
}