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


Java JMenu.add方法代码示例

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


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

示例1: init

import javax.swing.JMenu; //导入方法依赖的package包/类
private void init() {
    JMenu setPriority = new JMenu("Set Priority");
    JMenu addProp = new JMenu("Add Property");
    JMenu clearProp = new JMenu("Clear Property");
    JMenu deleteProp = new JMenu("Remove Property");

    setPriority.add(Utils.createMenuItem("Set Priority to Page", MobileORTable.this));
    setPriority.add(Utils.createMenuItem("Set Priority to All", MobileORTable.this));
    setPriority.add(Utils.createMenuItem("Set Priority to Selected", MobileORTable.this));
    add(setPriority);
    clearProp.add(Utils.createMenuItem("Clear from Page", MobileORTable.this));
    clearProp.add(Utils.createMenuItem("Clear from All", MobileORTable.this));
    clearProp.add(Utils.createMenuItem("Clear from Selected", MobileORTable.this));
    add(clearProp);
    deleteProp.add(Utils.createMenuItem("Remove from Page", MobileORTable.this));
    deleteProp.add(Utils.createMenuItem("Remove from All", MobileORTable.this));
    deleteProp.add(Utils.createMenuItem("Remove from Selected", MobileORTable.this));
    add(deleteProp);
    addProp.add(Utils.createMenuItem("Add to Page", MobileORTable.this));
    addProp.add(Utils.createMenuItem("Add to All", MobileORTable.this));
    addProp.add(Utils.createMenuItem("Add to Selected", MobileORTable.this));
    add(addProp);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:24,代码来源:MobileORTable.java

示例2: ScatterPopupMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
public ScatterPopupMenu() {
	restore = new JMenuItem("Original view");
	saveAs = new JMenuItem("Save as...");
	point = new JMenu("Point size");
	for (int i = 0; i < 5; i++) {
		JMenuItem m = new JMenuItem();
		m.setAction(commonActionSize);
		m.setText("Size " + Integer.toString((i + 1)));
		point.add(m);
	}

	this.add(restore);
	this.addSeparator();
	this.add(point);
	this.addSeparator();
	this.add(saveAs);
	addListeners();
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:19,代码来源:Scatter.java

示例3: createFileMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
public JMenu createFileMenu() {

		// Build the file menu.
		JMenu fileMenu = new JMenu("Tiedosto");

		createMenuItem(fileMenu, MENU_ITEM_NEW_PORTFOLIO, "Luo uusi salkku");
		openPortfolio = createMenuItem(fileMenu, MENU_ITEM_OPEN_PORTFOLIO,
				"Avaa salkku");
		openPortfolio.setEnabled(false);

		createMenuItem(fileMenu, MENU_ITEM_IMPORT_PORTFOLIO,
				"Luo uusi salkku Portfolio-ohjelman tiedostosta");
		fileMenu.add(new JSeparator()); // SEPARATOR
		createMenuItem(fileMenu, MENU_ITEM_QUIT, "Lopeta ohjelma");

		return fileMenu;
	}
 
开发者ID:skarna1,项目名称:javaportfolio,代码行数:18,代码来源:MenuCreator.java

示例4: prepareControls

import javax.swing.JMenu; //导入方法依赖的package包/类
protected void prepareControls() {
    frame = new JFrame("Mixing : Dropdown Overlapping test");
    frame.setLayout(new GridLayout(0,1));
    frame.setSize(200, 200);
    frame.setVisible(true);

    menuBar = new JMenuBar();
    JMenu menu = new JMenu("Test Menu");
    ActionListener menuListener = new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            lwClicked = true;
        }
    };

    JMenuItem item;
    menu.add(item = new JMenuItem("first"));
    item.addActionListener(menuListener);
    separator = new JSeparator();
    separator.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            spClicked = true;
        }
    });
    menu.add(separator);

    for (int i = 0; i < petStrings.length; i++) {
        menu.add(item = new JMenuItem(petStrings[i]));
        item.addActionListener(menuListener);
    }
    menuBar.add(menu);
    frame.setJMenuBar(menuBar);

    propagateAWTControls(frame);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:JMenuBarOverlapping.java

示例5: Gui

import javax.swing.JMenu; //导入方法依赖的package包/类
public Gui() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
	UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
	frame = new JFrame("ElectroLight Penetration Testing");
	menuBar = new JMenuBar();
	frame.setJMenuBar(menuBar);
	
	JMenu mnCounterhack = new JMenu("Counter-hack");
	menuBar.add(mnCounterhack);
	
	JMenuItem mntmArpScan = new JMenuItem("ARP Scan");
	mnCounterhack.add(mntmArpScan);
	frame.setSize(300, 200);
	
	JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
	frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
	
	// Always keep the 2 following lines at the end.
	//frame.pack();
	frame.setVisible(true);
}
 
开发者ID:Electro-Light,项目名称:ElectroLight-Penetration-Testing,代码行数:21,代码来源:Gui.java

示例6: createAnimationMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
private void createAnimationMenu() {
	animationMenu = new JMenu("Animation");
	animationMenu.setMnemonic(KeyEvent.VK_A);
	fileMenu.getAccessibleContext().setAccessibleDescription(
			"Manage the animation.");
	menuBar.add(animationMenu);
	animationMenu.setEnabled(false);

	initialiseItem = new JMenuItem("Initialise");
	initialiseItem.setMnemonic(KeyEvent.VK_I);
	initialiseItem.addActionListener(menuListener);
	animationMenu.add(initialiseItem);

	playPauseItem = new JMenuItem("Play");
	playPauseItem.setMnemonic(KeyEvent.VK_P);
	playPauseItem.addActionListener(menuListener);
	animationMenu.add(playPauseItem);

	stopItem = new JMenuItem("Stop");
	stopItem.setMnemonic(KeyEvent.VK_T);
	stopItem.addActionListener(menuListener);
	stopItem.setEnabled(false);
	animationMenu.add(stopItem);
}
 
开发者ID:moment-of-peace,项目名称:AI-RRT-Motion-Planning,代码行数:25,代码来源:Visualiser.java

示例7: createGUI

import javax.swing.JMenu; //导入方法依赖的package包/类
private static JFrame createGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("Some menu");
    menuBar.add(menu);

    for (int i = 0; i < 10; i++) {
        menu.add(new JMenuItem("Some menu #" + i));
    }

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setMinimumSize(new Dimension(200, 200));
    frame.setJMenuBar(menuBar);
    return frame;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:bug8071705.java

示例8: menuItem

import javax.swing.JMenu; //导入方法依赖的package包/类
/** Construct a new JMenuItem then add it to an existing JMenu.
 * @param parent - the JMenu to add this JMenuItem into (or null if you don't want to add it to any JMenu yet)
 * @param label - the text to show on the menu
 * @param attrs - a list of attributes to apply onto the new JMenuItem
 * <p> If one positive number  a is supplied, we call setMnemonic(a)
 * <p> If two positive numbers a and b are supplied, and a!=VK_ALT, and a!=VK_SHIFT, we call setMnemoic(a) and setAccelerator(b)
 * <p> If two positive numbers a and b are supplied, and a==VK_ALT or a==VK_SHIFT, we call setAccelerator(a | b)
 * <p> If an ActionListener is supplied, we call addActionListener(x)
 * <p> If an Boolean x      is supplied, we call setEnabled(x)
 * <p> If an Icon x         is supplied, we call setIcon(x)
 */
public static JMenuItem menuItem (JMenu parent, String label, Object... attrs) {
   JMenuItem m = new JMenuItem(label, null);
   int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
   boolean hasMnemonic = false;
   for(Object x: attrs) {
      if (x instanceof Character || x instanceof Integer) {
         int k = (x instanceof Character) ? ((int)((Character)x)) : ((Integer)x).intValue();
         if (k < 0) continue;
         if (k==KeyEvent.VK_ALT)   { hasMnemonic = true; accelMask = accelMask | InputEvent.ALT_MASK;   continue; }
         if (k==KeyEvent.VK_SHIFT) { hasMnemonic = true; accelMask = accelMask | InputEvent.SHIFT_MASK; continue; }
         if (!hasMnemonic) { m.setMnemonic(k); hasMnemonic=true; } else m.setAccelerator(KeyStroke.getKeyStroke(k, accelMask));
      }
      if (x instanceof ActionListener) m.addActionListener((ActionListener)x);
      if (x instanceof Icon) m.setIcon((Icon)x);
      if (x instanceof Boolean) m.setEnabled((Boolean)x);
   }
   if (parent!=null) parent.add(m);
   return m;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:31,代码来源:OurUtil.java

示例9: buildGameMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
private void buildGameMenu() {
    // --> Game
    JMenu menu = Utility.localizedMenu("menuBar.game");
    menu.setOpaque(false);
    menu.setMnemonic(KeyEvent.VK_G);

    menu.add(getMenuItem(NewAction.id));
    menu.add(getMenuItem(OpenAction.id));
    menu.add(getMenuItem(SaveAction.id));

    menu.addSeparator();

    menu.add(getMenuItem(PreferencesAction.id));
    menu.add(getMenuItem(ReconnectAction.id));

    menu.addSeparator();

    menu.add(getMenuItem(ChatAction.id));
    menu.add(getMenuItem(DeclareIndependenceAction.id));
    menu.add(getMenuItem(EndTurnAction.id));

    menu.addSeparator();

    menu.add(getMenuItem(ShowMainAction.id));
    menu.add(getMenuItem(ReportHighScoresAction.id));
    menu.add(getMenuItem(RetireAction.id));
    menu.add(getMenuItem(SaveAndQuitAction.id));
    menu.add(getMenuItem(QuitAction.id));

    add(menu);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:32,代码来源:InGameMenuBar.java

示例10: initializeMenus

import javax.swing.JMenu; //导入方法依赖的package包/类
private void initializeMenus () {
	{
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		{
			JMenu fileMenu = new JMenu();
			menuBar.add(fileMenu);
			fileMenu.setText("File");
			fileMenu.setMnemonic(KeyEvent.VK_F);
			{
				openMenuItem = new JMenuItem("Open Hiero settings file...");
				openMenuItem.setMnemonic(KeyEvent.VK_O);
				openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK));
				fileMenu.add(openMenuItem);
			}
			{
				saveMenuItem = new JMenuItem("Save Hiero settings file...");
				saveMenuItem.setMnemonic(KeyEvent.VK_S);
				saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
				fileMenu.add(saveMenuItem);
			}
			fileMenu.addSeparator();
			{
				saveBMFontMenuItem = new JMenuItem("Save BMFont files (text)...");
				saveBMFontMenuItem.setMnemonic(KeyEvent.VK_B);
				saveBMFontMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK));
				fileMenu.add(saveBMFontMenuItem);
			}
			fileMenu.addSeparator();
			{
				exitMenuItem = new JMenuItem("Exit");
				exitMenuItem.setMnemonic(KeyEvent.VK_X);
				fileMenu.add(exitMenuItem);
			}
		}
	}
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:38,代码来源:Hiero.java

示例11: getPopupPresenter

import javax.swing.JMenu; //导入方法依赖的package包/类
@Messages({
    "LBL_change_package_type=&View Java Packages as",
    "ChangePackageViewTypeAction_list=&List",
    "ChangePackageViewTypeAction_tree=&Tree",
    "ChangePackageViewTypeAction_reduced_tree=&Reduced Tree"
})
@Override public JMenuItem getPopupPresenter() {
    JMenu menu = new JMenu();
    Mnemonics.setLocalizedText(menu, LBL_change_package_type());
    menu.add(createChoice(JavaProjectSettings.PackageViewType.PACKAGES, ChangePackageViewTypeAction_list()));
    menu.add(createChoice(JavaProjectSettings.PackageViewType.TREE, ChangePackageViewTypeAction_tree()));
    menu.add(createChoice(JavaProjectSettings.PackageViewType.REDUCED_TREE, ChangePackageViewTypeAction_reduced_tree()));
    return menu;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ChangePackageViewTypeAction.java

示例12: createMenuBar

import javax.swing.JMenu; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void createMenuBar() {
	JMenuItem copy = new JMenuItem("Copy");
	copy.addActionListener(ae -> TransferableUtils.copyObject(Keyframe.deepCopy(keyframes)));
	copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.META_MASK));
	
	JMenuItem paste = new JMenuItem("Paste");
	paste.addActionListener(ae -> {
		Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this);
		try {
			ArrayList<Keyframe<Serializable>> data = (ArrayList<Keyframe<Serializable>>) t.getTransferData(TransferableUtils.objectDataFlavor);
			if(data.isEmpty())
				return;
			//Yes this is ugly. There is really no better way of doing it though. Forgive me
			if(data.get(0).getValue() instanceof Color)
				keyframes = (ArrayList<Keyframe<Color>>) (Object) data;
			refresh();
		} catch (UnsupportedFlavorException | IOException e1) {
			System.err.println("Invalid data copied");
		}
	});
	paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.META_MASK));
	
	JMenuBar bar = new JMenuBar();
	JMenu edit = new JMenu("Edit");
	edit.add(copy);
	edit.add(paste);
	bar.add(edit);
	setJMenuBar(bar);
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:31,代码来源:ColorInterpolator.java

示例13: getFittingMenubar

import javax.swing.JMenu; //导入方法依赖的package包/类
private void getFittingMenubar() {

		JMenuBar jmb = new JMenuBar();

		/*JMenuItem[][] menuItems = {{new JMenuItem(FILE_NEW),null, new JMenuItem(FILE_EXIT)},
		                           {new JMenuItem(ACTION_SOLVE),
		                            null, new JMenuItem(ACTION_NEXT), new JMenuItem(ACTION_PREV)},
		                           {new JMenuItem(HELP), null, new JMenuItem(ABOUT)} };*/
		JMenuItem[][] menuItems = { { new JMenuItem(FI_FILE_NEW), null, new JMenuItem(FI_FILE_EXIT) },
				{ new JMenuItem(FI_HELP), null, new JMenuItem(FI_ABOUT) } };

		String[] menuTitles = { "File", "Help" };
		char[] chars = { 'F', 'e' };
		for (int i = 0; i < menuItems.length; i++) {
			JMenu menu = new JMenu(menuTitles[i]);
			menu.setMnemonic(chars[i]);
			for (int j = 0; j < menuItems[i].length; j++) {
				if (menuItems[i][j] == null) {
					menu.addSeparator();
				} else {
					menu.add(menuItems[i][j]);
				}
			}
			jmb.add(menu);
		}
		setMenuBar(jmb);
	}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:28,代码来源:MainJwatWizard.java

示例14: addMenuItem

import javax.swing.JMenu; //导入方法依赖的package包/类
/**
 * Adds an item with no action under the given parent menu.
 * @param item the new item to be added
 * @param parentName the name of the menu under which the new item will be added
 * @param tooltip the description text that will be shown when the mouse is over this item
 * @param enabled indicates whether or not the item will be enabled
 */
public void addMenuItem(JMenuItem item, String parentName, String tooltip,
		boolean enabled) {
	JMenu parentMenu = (JMenu) parentMenus.get(parentName);
	
	if (parentMenu != null)
		parentMenu.add(item);
		
	item.setEnabled(enabled);
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:17,代码来源:Menu.java

示例15: createMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
public static JMenu createMenu(XML_Menu menuLayer) {
	JMenu menu = new JMenu(menuLayer.name);
	menuToMenuItem.put(menuLayer, menu);

	boolean isEnabled = false;

	for (XML_Menu sub_menu : menuLayer.child_layers) {
		if (sub_menu.proj != null) {
			//Don't do for imported sessions as we are now adding all sessions to the menu, and will
			//switch projection when loading.
			if ( !(menuLayer.parent != null && menuLayer.parent.name.equals("My Layer Sessions")) &&
					!menuLayer.name.equals("My Layer Sessions") &&
					!sub_menu.proj.toLowerCase().contains(MapApp.CURRENT_PROJECTION.toLowerCase())) {
				if ( sub_menu.separator_bar != null )
					menu.addSeparator();
				continue;
			}
		}
		if (sub_menu.os != null)
			if (!current_os.toLowerCase().contains(sub_menu.os.toLowerCase()))
				continue;

		if ( sub_menu.child_layers.size() > 0 ) {
			JMenu subMenu = createMenu(sub_menu);
			if (subMenu.getItemCount() != 0)
				menu.add(subMenu);

			isEnabled = isEnabled || subMenu.isEnabled();
		}
		else {
			JMenuItem mi = createMenuItem(sub_menu);

			isEnabled = isEnabled || mi.isEnabled();

			if ( sub_menu.separator_bar != null ) {
				if ( sub_menu.separator_bar.equals("above")) {
					menu.addSeparator();
					menu.add(mi);
				}
				else {
					menu.add(mi);
					menu.addSeparator();
				}
			}
			else {
				menu.add(mi);
			}
		}
	}

	if ("true".equalsIgnoreCase(menuLayer.isRemote) && MapApp.AT_SEA)
		menu.setEnabled(false);
	else
		menu.setEnabled(isEnabled);

	return menu;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:58,代码来源:XML_Menu.java


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