當前位置: 首頁>>代碼示例>>Java>>正文


Java Menu.add方法代碼示例

本文整理匯總了Java中java.awt.Menu.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Menu.add方法的具體用法?Java Menu.add怎麽用?Java Menu.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Menu的用法示例。


在下文中一共展示了Menu.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initProjectMenu

import java.awt.Menu; //導入方法依賴的package包/類
private static Menu initProjectMenu() {
  Menu mnProject = new Menu(Resources.get("menu_project"));

  CheckboxMenuItem compress = new CheckboxMenuItem(Resources.get("menu_compressProjectFile"));
  compress.setState(userPreferences.isCompressFile());
  compress.addItemListener(e -> userPreferences.setCompressFile(compress.getState()));

  CheckboxMenuItem sync = new CheckboxMenuItem(Resources.get("menu_syncMaps"));
  sync.setState(userPreferences.isSyncMaps());
  sync.addItemListener(e -> userPreferences.setSyncMaps(sync.getState()));

  MenuItem importSpriteFile = new MenuItem(Resources.get("menu_assets_importSpriteFile"));
  importSpriteFile.addActionListener(a -> EditorScreen.instance().importSpriteFile());

  MenuItem importSprite = new MenuItem(Resources.get("menu_assets_importSprite"));
  importSprite.addActionListener(a -> EditorScreen.instance().importSprites());

  mnProject.add(importSprite);
  mnProject.add(importSpriteFile);
  mnProject.addSeparator();
  mnProject.add(compress);
  mnProject.add(sync);

  return mnProject;
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:26,代碼來源:Program.java

示例2: generateMenuItem

import java.awt.Menu; //導入方法依賴的package包/類
private static MenuItem generateMenuItem(TreeElement element) {
    if(element.isLeaf()) {
        MenuItem item = new MenuItem(element.getCaption());
        item.addActionListener(new MasterFrameMenu(element.getFullID()));
        if(element.isHidden()) {
            item.setEnabled(false);
        } else if(!element.getEnabled()) {
            item.setEnabled(false);
        }
        items.put(element.getFullID(), item);
        return(item);
    } else {
        Menu menu = new Menu(element.getCaption());
        Iterator<TreeElement> i = element.getChilds();
        while(i.hasNext()) {
            menu.add(generateMenuItem(i.next()));
        }
        if(element.isHidden()) {
            menu.setEnabled(false);
        }
        items.put(element.getFullID(), menu);
        return(menu);
    }
}
 
開發者ID:Martin-Dames,項目名稱:Tingeltangel,代碼行數:25,代碼來源:MasterFrameMenu.java

示例3: addMenuItems

import java.awt.Menu; //導入方法依賴的package包/類
/**
 * Method declaration
 *
 *
 * @param f
 * @param m
 */
private void addMenuItems(Menu f, String[] m) {

    for (int i = 0; i < m.length; i++) {
        if (m[i].equals("-")) {
            f.addSeparator();
        } else {
            MenuItem item = new MenuItem(m[i]);

            item.addActionListener(this);
            f.add(item);
        }
    }
}
 
開發者ID:anhnv-3991,項目名稱:VoltDB,代碼行數:21,代碼來源:Transfer.java

示例4: main

import java.awt.Menu; //導入方法依賴的package包/類
public static void main(String[] args) {
	
	Container container = new Container();
	Panel panel = new Panel();
	Menu menu = new Menu();	   			//!!! its not component
	TextField textField = new TextField();
	container.add(textField);
	
	Window win = new Window(null);
	win.pack();
	
	
	menu.setShortcut(new MenuShortcut(12));
	new MenuItem("label", new MenuShortcut(33, true));
	
	Menu file = new Menu("File"); 
	MenuItem print; 
	file.add(print = new MenuItem("Print", new MenuShortcut('p'))); 

}
 
開發者ID:wandrusz,項目名稱:wwwa,代碼行數:21,代碼來源:AWTExample.java

示例5: createPopupMenu

import java.awt.Menu; //導入方法依賴的package包/類
protected static PopupMenu createPopupMenu() {
    final PopupMenu popup = new PopupMenu();
    MenuItem aboutItem = new MenuItem("About");
    CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size");
    CheckboxMenuItem cb2 = new CheckboxMenuItem("Set tooltip");
    Menu displayMenu = new Menu("Display");
    MenuItem errorItem = new MenuItem("Error");
    MenuItem warningItem = new MenuItem("Warning");
    MenuItem infoItem = new MenuItem("Info");
    MenuItem noneItem = new MenuItem("None");
    MenuItem exitItem = new MenuItem("Exit");
    // Add components to pop-up menu
    popup.add(aboutItem);
    popup.addSeparator();
    popup.add(cb1);
    popup.add(cb2);
    popup.addSeparator();
    popup.add(displayMenu);
    displayMenu.add(errorItem);
    displayMenu.add(warningItem);
    displayMenu.add(infoItem);
    displayMenu.add(noneItem);
    popup.add(exitItem);
    return popup;
}
 
開發者ID:SaiPradeepDandem,項目名稱:javafx-demos,代碼行數:26,代碼來源:TrayLeftClick.java

示例6: OpenPartnerFrame

import java.awt.Menu; //導入方法依賴的package包/類
public OpenPartnerFrame (Go go)
{
	super(Global.resourceString("Open_Partners"));
	G = go;
	MenuBar mb = new MenuBar();
	setMenuBar(mb);
	Menu m = new MyMenu(Global.resourceString("Options"));
	m.add(new MenuItemAction(this, Global.resourceString("Close")));
	mb.add(m);
	setLayout(new BorderLayout());
	L = new java.awt.List();
	L.setFont(Global.SansSerif);
	refresh();
	add("Center", L);
	JPanel bp = new MyPanel();
	bp.add(new ButtonAction(this, Global.resourceString("Connect")));
	bp.add(new ButtonAction(this, Global.resourceString("Refresh")));
	bp.add(new MyLabel(" "));
	bp.add(new ButtonAction(this, Global.resourceString("Close")));
	add("South", bp);
	Global.setwindow(this, "openpartner", 300, 200);
	seticon("ijago.gif");
	setVisible(true);
	OPFU = new OpenPartnerFrameUpdate(this);
}
 
開發者ID:Zenigata,項目名稱:jago,代碼行數:26,代碼來源:OpenPartnerFrame.java

示例7: initFileMenu

import java.awt.Menu; //導入方法依賴的package包/類
private static Menu initFileMenu() {
  Menu mnFile = new Menu(Resources.get("menu_file"));

  MenuItem create = new MenuItem(Resources.get("menu_createProject"));
  create.setShortcut(new MenuShortcut(KeyEvent.VK_N));
  create.addActionListener(a -> EditorScreen.instance().create());

  MenuItem load = new MenuItem(Resources.get("menu_loadProject"));
  load.setShortcut(new MenuShortcut(KeyEvent.VK_O));
  load.addActionListener(a -> EditorScreen.instance().load());

  MenuItem save = new MenuItem(Resources.get("menu_save"));
  save.setShortcut(new MenuShortcut(KeyEvent.VK_S));
  save.addActionListener(a -> EditorScreen.instance().save(false));

  MenuItem saveAs = new MenuItem(Resources.get("menu_saveAs"));
  saveAs.addActionListener(a -> EditorScreen.instance().save(true));

  MenuItem exit = new MenuItem(Resources.get("menu_exit"));
  exit.setShortcut(new MenuShortcut(KeyEvent.VK_Q));
  exit.addActionListener(a -> Game.terminate());

  mnFile.add(load);
  mnFile.add(create);
  mnFile.add(save);
  mnFile.add(saveAs);
  mnFile.addSeparator();
  recentFiles = new Menu(Resources.get("menu_recentFiles"));
  loadRecentFiles();
  mnFile.add(recentFiles);
  mnFile.addSeparator();
  mnFile.add(exit);
  return mnFile;
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:35,代碼來源:Program.java

示例8: addMenuItems

import java.awt.Menu; //導入方法依賴的package包/類
void addMenuItems(Menu f, String[] m) {

        for (int i = 0; i < m.length; i++) {
            MenuItem item = new MenuItem(m[i].substring(1));
            char     c    = m[i].charAt(0);

            if (c != '-') {
                item.setShortcut(new MenuShortcut(c));
            }

            item.addActionListener(this);
            f.add(item);
        }
    }
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:15,代碼來源:DatabaseManager.java

示例9: main

import java.awt.Menu; //導入方法依賴的package包/類
/**
 * Method declaration
 *
 *
 * @param arg
 */
public static void main(String[] arg) {

    fMain = new Frame("Query Tool");

    QueryTool q = new QueryTool();

    q.bApplication = true;

    for (int i = 0; i < arg.length; i++) {
        String p = arg[i];

        if (p.equals("-?")) {
            printHelp();
        }

        if (p.charAt(0) == '-') {
            pProperties.put(p.substring(1), arg[i + 1]);

            i++;
        }
    }

    q.init();
    q.start();
    fMain.add("Center", q);

    MenuBar menu = new MenuBar();
    Menu    file = new Menu("File");

    file.add("Exit");
    file.addActionListener(q);
    menu.add(file);
    fMain.setMenuBar(menu);
    fMain.setSize(500, 400);
    fMain.show();
    fMain.addWindowListener(q);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:44,代碼來源:QueryTool.java

示例10: addMenuItems

import java.awt.Menu; //導入方法依賴的package包/類
/**
 * Method declaration
 *
 *
 * @param f
 * @param m
 */
void addMenuItems(Menu f, String m[]) {

    for (int i = 0; i < m.length; i++) {
        MenuItem item = new MenuItem(m[i].substring(1));
        char     c    = m[i].charAt(0);

        if (c != '-') {
            item.setShortcut(new MenuShortcut(c));
        }

        item.addActionListener(this);
        f.add(item);
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:DatabaseManager.java

示例11: addMenuItems

import java.awt.Menu; //導入方法依賴的package包/類
/**
 * Method declaration
 *
 *
 * @param f
 * @param m
 */
private void addMenuItems(Menu f, String m[]) {

    for (int i = 0; i < m.length; i++) {
        if (m[i].equals("-")) {
            f.addSeparator();
        } else {
            MenuItem item = new MenuItem(m[i]);

            item.addActionListener(this);
            f.add(item);
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:Transfer.java

示例12: main

import java.awt.Menu; //導入方法依賴的package包/類
/**
 * Method declaration
 *
 *
 * @param arg
 */
public static void main(String arg[]) {

    fMain = new Frame("Query Tool");

    QueryTool q = new QueryTool();

    q.bApplication = true;

    for (int i = 0; i < arg.length; i++) {
        String p = arg[i];

        if (p.equals("-?")) {
            printHelp();
        }

        if (p.charAt(0) == '-') {
            pProperties.put(p.substring(1), arg[i + 1]);

            i++;
        }
    }

    q.init();
    q.start();
    fMain.add("Center", q);

    MenuBar menu = new MenuBar();
    Menu    file = new Menu("File");

    file.add("Exit");
    file.addActionListener(q);
    menu.add(file);
    fMain.setMenuBar(menu);
    fMain.setSize(500, 400);
    fMain.show();
    fMain.addWindowListener(q);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:44,代碼來源:QueryTool.java

示例13: ActionEventTest

import java.awt.Menu; //導入方法依賴的package包/類
public ActionEventTest() {
    menuBar = new MenuBar();
    Menu menu = new Menu("Menu1");
    MenuItem menuItem = new MenuItem("MenuItem");

    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            System.out.println("actionPerformed");
            int md = ae.getModifiers();
            int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
                    | ActionEvent.SHIFT_MASK;

            isProgInterruption = true;
            mainThread.interrupt();
            if ((md & expectedMask) != expectedMask) {
                throw new RuntimeException("Action Event modifiers are not"
                    + " set correctly.");
            }
        }
    });
    menu.add(menuItem);
    menuBar.add(menu);
    setMenuBar(menuBar);

    instructions = new TextArea(10, 50);
    instructions.setText(
    " This is a manual test\n" +
    " Keep the Alt, Shift & Ctrl Keys pressed while doing next steps\n" +
    " Click 'Menu1' Menu from the Menu Bar\n" +
    " It will show 'MenuItem'\n" +
    " Left mouse Click the 'MenuItem'\n" +
    " Test exits automatically after mouse click.");
    add(instructions);

    setSize(400, 400);
    setVisible(true);
    validate();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:40,代碼來源:ActionEventTest.java

示例14: createMenuBar

import java.awt.Menu; //導入方法依賴的package包/類
private MenuBar createMenuBar(Container contentPane) {
	menubar = new MenuBar();
	
	menu = new Menu();
	menu.setLabel("Action");
	
	menuItem = new MenuItem();
	menuItem.setLabel("Append");
	
	menu.add(menuItem);	
	menubar.add(menu);
	
	return menubar;
}
 
開發者ID:allbutone,項目名稱:javatalk,代碼行數:15,代碼來源:Java_Swing_Quiz.java

示例15: addAudioInputs

import java.awt.Menu; //導入方法依賴的package包/類
private void addAudioInputs( Menu menu )
{
    SelectInput select_input = SelectInput.getInstance();
    RadioMenuItemGroup input_group = new RadioMenuItemGroup();
    for ( int i = 0; i < select_input.getInputs().length; i++ )
    {
        boolean state = false;
        if ( select_input.getInputs()[i].getName().equals( "Soundflower (2ch)" ) )
        {
            state = true;
        }

        final int index = i;
        RadioMenuItem audio_option = new RadioMenuItem(
                select_input.getInputs()[i].getName(), input_group, state );
        audio_option.addItemListener( new ItemListener()
        {
            @Override
            public void itemStateChanged( ItemEvent e )
            {
                if ( e.getStateChange() == ItemEvent.SELECTED )
                {
                    new Message( "Switching inputs to " + SelectInput
                                 .getInstance().getInputs()[index].getName() +
                                 "\nThis is an experimental feature." );
                    SelectInput.getInstance().refresh();
                    in.close();
                    in = SelectInput.getInstance().setInput(
                            SelectInput.getInstance().getInputs()[index] );
                }
            }
        });

        menu.add( audio_option );
    }
}
 
開發者ID:uPaymeiFixit,項目名稱:Processing-Arduino-Light-Controller,代碼行數:37,代碼來源:SystemTrayHandler.java


注:本文中的java.awt.Menu.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。