當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。