javax.swing.JMenuItem.add()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中javax.swing.JMenuItem.add()方法的一些代码示例,展示了JMenuItem.add()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.add()方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:add

JMenuItem.add介绍

暂无

代码示例

代码示例来源:origin: 4thline/cling

menuItem.add(instanceItem);

代码示例来源:origin: stackoverflow.com

JPopupMenu menu = new JPopupMenu();
menu.add(new JMenuItem("remove"));
JMenuItem addItem = new JMenu("add");
menu.add(addItem);

addItem.add(new JMenuItem("pizza"));
addItem.add(new JMenuItem("cake"));

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf

private JMenuItem createSubmenu () {
  FiltersDescription filtersDesc = filters.getDescription();
  JMenuItem menu = new JMenu(NbBundle.getMessage(FilterSubmenuAction.class, "LBL_FilterSubmenu")); //NOI18N
  JMenuItem menuItem = null;
  String filterName = null;
  for (int i = 0; i < filtersDesc.getFilterCount(); i++) {
    filterName = filtersDesc.getName(i);
    menuItem = new JCheckBoxMenuItem(
        filtersDesc.getDisplayName(i), filters.isSelected(filterName)); 
    menuItem.addActionListener(this);
    menuItem.putClientProperty(PROP_FILTER_NAME, filterName);
    menu.add(menuItem);
  }
  return menu;
}

代码示例来源:origin: stackoverflow.com

JMenuItem item = new JMenuItem("Edit                       ");
item.setLayout( new FlowLayout(FlowLayout.RIGHT, 5, 0) );
JButton copy = new JButton("Copy");
copy.setMargin(new Insets(0, 2, 0, 2) );
item.add( copy );
menu.add( item );

代码示例来源:origin: iTransformers/netTransformer

freeGraphDiffSettings.add(freeGraphIgnoredEdgeKeys);
freeGraph.add(freeGraphDiffSettings);
configuration.add(freeGraph);

代码示例来源:origin: stackoverflow.com

private void addRestartHint(JMenuItem m, String text) {
  final String spaceholder = "                                        ";
  String t = m.getText() + spaceholder;
  m.setLayout(new BorderLayout());
  m.setText(t);
  m.add(new JLabel(text), BorderLayout.EAST);
}

代码示例来源:origin: com.darwinsys/darwinsys-api

insertMenu.add(menuItem);
JMenuItem menuItem2 = new JMenuItem(".signature");
menuItem2.setEnabled(false);
insertMenu.add(menuItem2);
JMenuItem menuItem3 = new JMenuItem("File...");
menuItem3.setEnabled(false);
insertMenu.add(menuItem3);
mb.add(em);

代码示例来源:origin: stackoverflow.com

JMenu menu = new JMenu("Menu");

JMenuItem item = new JMenuItem("Add");
item.add(new JButton("SOMETHING A BIT WORDY"));
item.setLayout(new FlowLayout()); // set FlowLayout for item
item.setPreferredSize(new Dimension(200, 100)); // hard code implementation :-(
menu.add(item);

// ... 
JMenuBar menuBar = new JMenuBar();
menuBar.add(menu);
JFrame frame = new JFrame();
frame.setJMenuBar(menuBar);

// ...
frame.pack();
frame.setVisible(true);

代码示例来源:origin: IanDarwin/darwinsys-api

insertMenu.add(menuItem);
JMenuItem menuItem2 = new JMenuItem(".signature");
menuItem2.setEnabled(false);
insertMenu.add(menuItem2);
JMenuItem menuItem3 = new JMenuItem("File...");
menuItem3.setEnabled(false);
insertMenu.add(menuItem3);
mb.add(em);

代码示例来源:origin: stackoverflow.com

main = new JMenuItem(abstractMenu.getMenuName());
jMenuItem.add(main);

代码示例来源:origin: otros-systems/otroslogviewer

JMenuItem autoResizeOff = new JMenuItem("Auto resize off");
autoResizeOff.addActionListener(new TableResizeActionListener(table, JTable.AUTO_RESIZE_OFF));
autoResizeMenu.add(autoResizeSubsequent);
autoResizeMenu.add(autoResizeOff);
autoResizeMenu.add(autoResizeNext);
autoResizeMenu.add(autoResizeLast);
autoResizeMenu.add(autoResizeAll);
JMenu removeMenu = new JMenu("Remove log events");
removeMenu.setFont(menuLabelFont);

代码示例来源:origin: cytoscape/application

private void updateVSMenu() {
    applyVisualStyleMenu.removeAll();
    
    final Set<String> vsNames = new TreeSet<String>(Cytoscape.getVisualMappingManager().getCalculatorCatalog().getVisualStyleNames());
    for (String name: vsNames) {
      final JMenuItem styleMenu = new JMenuItem(name);
      styleMenu.setAction(new ApplyVisualStyleAction(name));
      applyVisualStyleMenu.add(styleMenu);
    }
  }
}

代码示例来源:origin: igvteam/igv

item.add(p);
double w = p.getPreferredSize().getWidth();
double h = p.getPreferredSize().getHeight();

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

JMenu submenu = new JMenu(split[i]);
  if (container == null) {
    item.add(submenu);
  } else {
    container.add(submenu);
  item.add(menuItem.getItem());
else
  container.add(menuItem.getItem());

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

helper.init(viewer, entities);
helper.getItem().setText(rt.toString() + " (" + invisibleRTCounts.get(rt) + ":" + allRTCounts.get(rt) + ")");
item.add(helper.getItem());

代码示例来源:origin: MrCrayfish/ModelCreator

item.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
JLabel label = new JLabel("<html><p style='color:#666666;font-size:9px'>" + shortcutText + "<p></html>");
item.add(label);
Dimension size = new Dimension((int) Math.ceil(item.getPreferredSize().getWidth() + label.getPreferredSize().getWidth()) + 10, 20);
item.setPreferredSize(size);

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

helper.init(viewer, entities);
helper.getItem().setText(cc.toString() + " (" + invisibleCCCounts.get(cc) + ":" + allCCCounts.get(cc) + ")");
item.add(helper.getItem());

代码示例来源:origin: net.java.openjdk.cacio/cacio-shared

public void addItem(MenuItem item) {
  MenuItemPeer mip = (MenuItemPeer) item.getPeer();
  if (mip == null) {
    item.addNotify();
    mip = (MenuItemPeer) item.getPeer();
  }
  assert mip instanceof CacioMenuItemPeer;
  JMenuItem jmi = ((CacioMenuItemPeer) mip).getSwingMenu();
  getSwingMenu().add(jmi);
}

代码示例来源:origin: omegat-org/omegat

/**
 * Test of bindKeyStrokes method, of class PropertiesShortcuts.
 */
@Test
public void testBindKeyStrokesJMenuBar() {
  JMenuBar menu = new JMenuBar();
  JMenu parent = new JMenu();
  JMenuItem child1 = new JMenu();
  JMenuItem child2 = new JMenuItem();
  child2.setActionCommand(TEST_DELETE);
  child2.setAccelerator(CTRL_D);
  JMenuItem grandchild1 = new JMenuItem();
  grandchild1.setActionCommand(TEST_USER_1);
  JMenuItem grandchild2 = new JMenuItem();
  grandchild2.setActionCommand(OUT_OF_LIST);
  grandchild2.setAccelerator(CTRL_X);
  menu.add(parent);
  parent.add(child1);
  parent.add(child2);
  child1.add(grandchild1);
  child1.add(grandchild2);
  // bind
  shortcuts.bindKeyStrokes(menu);
  assertNull(parent.getAccelerator());
  assertNull(child1.getAccelerator());
  assertNull(child2.getAccelerator());
  assertEquals(CTRL_P, grandchild1.getAccelerator());
  assertEquals(CTRL_X, grandchild2.getAccelerator());
}

代码示例来源:origin: omegat-org/omegat

/**
 * Test of bindKeyStrokes method, of class PropertiesShortcuts.
 */
@Test
public void testBindKeyStrokesJMenuItemRecursive() {
  // case JMenu with children
  JMenu parent = new JMenu();
  JMenuItem child1 = new JMenu();
  JMenuItem child2 = new JMenuItem();
  child2.setActionCommand(TEST_DELETE);
  child2.setAccelerator(CTRL_D);
  JMenuItem grandchild1 = new JMenuItem();
  grandchild1.setActionCommand(TEST_USER_1);
  JMenuItem grandchild2 = new JMenuItem();
  grandchild2.setActionCommand(OUT_OF_LIST);
  grandchild2.setAccelerator(CTRL_X);
  parent.add(child1);
  parent.add(child2);
  child1.add(grandchild1);
  child1.add(grandchild2);
  // bind
  shortcuts.bindKeyStrokes(parent);
  assertNull(parent.getAccelerator());
  assertNull(child1.getAccelerator());
  assertNull(child2.getAccelerator());
  assertEquals(CTRL_P, grandchild1.getAccelerator());
  assertEquals(CTRL_X, grandchild2.getAccelerator());
}

相关文章

JMenuItem类方法