当前位置: 首页>>代码示例>>Java>>正文


Java JPopupMenu类代码示例

本文整理汇总了Java中javax.swing.JPopupMenu的典型用法代码示例。如果您正苦于以下问题:Java JPopupMenu类的具体用法?Java JPopupMenu怎么用?Java JPopupMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JPopupMenu类属于javax.swing包,在下文中一共展示了JPopupMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EditEdgeMenu

import javax.swing.JPopupMenu; //导入依赖的package包/类
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();
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:25,代码来源:EditEdgeMenu.java

示例2: createPopupMenu

import javax.swing.JPopupMenu; //导入依赖的package包/类
@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;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:17,代码来源:MetaDataDeclarationEditor.java

示例3: buildPopupMenu

import javax.swing.JPopupMenu; //导入依赖的package包/类
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;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:ConfigureTree.java

示例4: createPopup

import javax.swing.JPopupMenu; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TableView.java

示例5: createContextMenu

import javax.swing.JPopupMenu; //导入依赖的package包/类
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);
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:22,代码来源:XDMMainWindow.java

示例6: showPopup

import javax.swing.JPopupMenu; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:OutlineView.java

示例7: getToolbarPresenter

import javax.swing.JPopupMenu; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ProfilerToolbarDropdownAction.java

示例8: doSelect

import javax.swing.JPopupMenu; //导入依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ButtonPopupSwitcher.java

示例9: actionPerformed

import javax.swing.JPopupMenu; //导入依赖的package包/类
@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");
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:27,代码来源:JPanelOwnMTP.java

示例10: AePlayerAdvancedControlsPanel

import javax.swing.JPopupMenu; //导入依赖的package包/类
/**
     * 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());
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:24,代码来源:AePlayerAdvancedControlsPanel.java

示例11: buildMenuElementArray

import javax.swing.JPopupMenu; //导入依赖的package包/类
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();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:36,代码来源:RMenuItem.java

示例12: MenuScroller

import javax.swing.JPopupMenu; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:34,代码来源:MenuScroller.java

示例13: mousePressed

import javax.swing.JPopupMenu; //导入依赖的package包/类
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());
    }
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:19,代码来源:HtmlChart.java

示例14: actionPerformed

import javax.swing.JPopupMenu; //导入依赖的package包/类
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);
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:20,代码来源:EntryPanel.java

示例15: makeMouseMenu

import javax.swing.JPopupMenu; //导入依赖的package包/类
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;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:10,代码来源:ExactTable.java


注:本文中的javax.swing.JPopupMenu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。