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


Java MenuBar.add方法代码示例

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


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

示例1: addMenu

import java.awt.MenuBar; //导入方法依赖的package包/类
void addMenu(MenuBar b, String name, String[] items) {

        /* It's a very poor design to encapsulate menu creation this way.
         * Can't customize the menus this way (e.g. shortcut keys,
         * mnemonics, disabling, etc. */
        Menu menu = new Menu(name);

        if (name.equals("Tools") && !TT_AVAILABLE) {

            // Terrible place to do this.  Forced to due to method design.
            menu.setEnabled(false);
        }

        addMenuItems(menu, items);
        b.add(menu);
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:17,代码来源:DatabaseManager.java

示例2: addMenu

import java.awt.MenuBar; //导入方法依赖的package包/类
/**
 * Method declaration
 *
 *
 * @param b
 * @param name
 * @param items
 */
void addMenu(MenuBar b, String name, String[] items) {

    /* It's a very poor design to encapsulate menu creation this way.
     * Can't customize the menus this way (e.g. shortcut keys,
     * mnemonics, disabling, etc. */
    Menu menu = new Menu(name);

    if (name.equals("Tools") && !TT_AVAILABLE) {

        // Terrible place to do this.  Forced to due to method design.
        menu.setEnabled(false);
    }

    addMenuItems(menu, items);
    b.add(menu);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:DatabaseManager.java

示例3: OpenPartnerFrame

import java.awt.MenuBar; //导入方法依赖的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

示例4: main

import java.awt.MenuBar; //导入方法依赖的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

示例5: main

import java.awt.MenuBar; //导入方法依赖的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

示例6: ActionEventTest

import java.awt.MenuBar; //导入方法依赖的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

示例7: createMenuBar

import java.awt.MenuBar; //导入方法依赖的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

示例8: MessageFilterEdit

import java.awt.MenuBar; //导入方法依赖的package包/类
public MessageFilterEdit (ListClass f)
{
	super(Global.resourceString("Message_Filter"));
	MenuBar mb = new MenuBar();
	setMenuBar(mb);
	Menu m = new MyMenu(Global.resourceString("Options"));
	m.add(new MenuItemAction(this, Global.resourceString("Close")));
	mb.add(m);
	F = f;
	L = new java.awt.List();
	L.setFont(Global.SansSerif);
	add("Center", new Panel3D(L));
	ListElement e = F.first();
	while (e != null)
	{
		L.add(((SingleMessageFilter)e.content()).Name);
		e = e.next();
	}
	JPanel p = new MyPanel();
	p.add(new ButtonAction(this, Global.resourceString("Edit")));
	p.add(new ButtonAction(this, Global.resourceString("New")));
	p.add(new ButtonAction(this, Global.resourceString("Delete")));
	p.add(new MyLabel(" "));
	p.add(new ButtonAction(this, Global.resourceString("OK")));
	add("South", new Panel3D(p));
	seticon("ijago.gif");
	Global.setwindow(this, "filteredit", 300, 300);
	validate();
	setVisible(true);
}
 
开发者ID:Zenigata,项目名称:jago,代码行数:31,代码来源:MessageFilter.java

示例9: GamesFrame

import java.awt.MenuBar; //导入方法依赖的package包/类
public GamesFrame (ConnectionFrame cf, PrintWriter out, IgsStream in)
{
	super(Global.resourceString("_Games_"));
	cf.addCloseListener(this);
	In = in;
	Out = out;
	MenuBar mb = new MenuBar();
	setMenuBar(mb);
	Menu m = new MyMenu(Global.resourceString("Options"));
	m.add(new MenuItemAction(this, Global.resourceString("Close")));
	mb.add(m);
	Menu help = new MyMenu(Global.resourceString("Help"));
	help.add(new MenuItemAction(this, Global
		.resourceString("About_this_Window")));
	mb.add(help);
	setLayout(new BorderLayout());
	T = Global.getParameter("systemlister", false)?new SystemLister()
		:new Lister();
	T.setFont(Global.Monospaced);
	T.setText(Global.resourceString("Loading"));
	add("Center", T);
	MyPanel p = new MyPanel();
	p.add(new ButtonAction(this, Global.resourceString("Observe")));
	p.add(new ButtonAction(this, Global.resourceString("Peek")));
	p.add(new ButtonAction(this, Global.resourceString("Status")));
	p.add(new MyLabel(" "));
	p.add(new ButtonAction(this, Global.resourceString("Refresh")));
	p.add(new ButtonAction(this, Global.resourceString("Close")));
	add("South", new Panel3D(p));
	CF = cf;
	GD = null;
	seticon("igames.gif");
	PopupMenu pop = new PopupMenu();
	addpop(pop, Global.resourceString("Observe"));
	addpop(pop, Global.resourceString("Peek"));
	addpop(pop, Global.resourceString("Status"));
	if (T instanceof Lister) T.setPopupMenu(pop);
}
 
开发者ID:Zenigata,项目名称:jago,代码行数:39,代码来源:GamesFrame.java

示例10: IntegratedWQI

import java.awt.MenuBar; //导入方法依赖的package包/类
public IntegratedWQI(NodeSchema tree) {

     
    
     JFrame frame =   new JFrame("Vertical Search Engine Version 1.0");
      panelPrincipal = new JPanel();
     JTabbedPane tabbedPane = new JTabbedPane();
     Component panel1 = makeTextPanel("Busqueda");
     InterfazUnifiedWQI intLibro = new InterfazUnifiedWQI(frame,tree);
  
     Component panel3 = intLibro.gestionLibros();
     tabbedPane.addTab("Searching WQIs", new ImageIcon(
        "com/bvertical/imagenes/libro.gif"), panel3, "Searching WQIs");
  
  /* cada una de las pesta�as */
     tabbedPane
        .addTab("Information...", new ImageIcon(
        		"com/bvertical/imagenes/prestamos.gif"), panel1,
        		"Information...");
  // tabbedPane.setBackgroundAt(Color.yellow) //agregarcolor
  
  // Add the tabbed pane to this panel.
     panelPrincipal.setLayout(new GridLayout(1, 1));
     panelPrincipal.add(tabbedPane);
  
     addWindowListener(
           new WindowAdapter() {
              public void windowClosing(WindowEvent e) {
                 System.exit(0);
              
              }
           });
  
     getContentPane().add(panelPrincipal);// ,
  
  /* Menus */
  
     MenuItem menuImprimirVencidos = new MenuItem("Opcion 1");
     MenuItem menuImprimirPrestamos = new MenuItem("Opcion 2");
     MenuItem menuImprimirListadoLibros = new MenuItem("Opcion 3");
  
     MenuItem menuInfoLibros = new MenuItem("Libros");
  
     menuImprimirVencidos.addActionListener(this);
     menuImprimirPrestamos.addActionListener(this);
     menuImprimirListadoLibros.addActionListener(this);
     menuInfoLibros.addActionListener(this);
  
     Menu menuImprimir = new Menu("Imprimir");
     Menu menuInfo = new Menu("Informaci�n");
  
     menuImprimir.add(menuImprimirVencidos);
     menuImprimir.add(menuImprimirPrestamos);
     menuImprimir.add(menuImprimirListadoLibros);
  
     menuInfo.add(menuInfoLibros);
  
  // Instancia un objeto MenuBar y le a�ade el objeto Menu previamente
  // definida.
     MenuBar barraMenu = new MenuBar();
     barraMenu.add(menuImprimir);
     barraMenu.add(menuInfo);
  
  // Se instancia un objeto Frame y se le asocian los objetos MenuBar
  // anteriores.
  
     setMenuBar(barraMenu);
  
     setSize(620, 440);
     setVisible(true);
     setLocation(300, 150);
  
  }
 
开发者ID:hmarinc,项目名称:Vsearch,代码行数:74,代码来源:IntegratedWQI.java

示例11: initMenuBar

import java.awt.MenuBar; //导入方法依赖的package包/类
void initMenuBar(){
  MenuBar mb = new MenuBar();  
  mb.add(mF = new Menu("File"));
  mF.add(mOF = new RedirectingMenuItem(p,"Open Model", new MenuShortcut( KeyEvent.VK_O )));  
  mF.add(mSF = new RedirectingMenuItem(p,"Save Model", new MenuShortcut( KeyEvent.VK_S )));  mSF.setEnabled(false);
  mF.add(mSFA = new RedirectingMenuItem(p,"Save Model as", null));  mSFA.setEnabled(false);
  mF.addSeparator();
  mF.add(mFD = new RedirectingMenuItem(p,"Load Data", null));  mFD.setEnabled(false);
  mF.add(mFNS = new RedirectingMenuItem(p,"Load NanoString", null));  mFNS.setEnabled(false);

  
  
   mb.add(mE = new Menu("Export"));
   mE.add(mERT = new RedirectingMenuItem(p,"Rules in TXT", null)); mERT.setEnabled(false);
   mE.add(mERP = new RedirectingMenuItem(p,"Rules in PDF", null)); mERP.setEnabled(false);
   mE.addSeparator();
   mE.add(mEMC = new RedirectingMenuItem(p,"Model in CSV", null)); mEMC.setEnabled(false);
   mE.add(mEMP = new RedirectingMenuItem(p,"Model in PDF", null)); mEMP.setEnabled(false);
   mE.addSeparator();
   mE.add(mEDP = new RedirectingMenuItem(p,"DATA in PDF", null)); mEDP.setEnabled(false);
   mE.add(mECP = new RedirectingMenuItem(p,"Compare in PDF", null)); mECP.setEnabled(false);
   
   mb.add(mW = new Menu("Windows"));
   mW.add(mWSe = new RedirectingCheckboxMenuItem(p,"Search...", false)); mWSe.setEnabled(false);
   mW.add(mWCo = new RedirectingCheckboxMenuItem(p,"Colors", false));
   mW.addSeparator();
   mW.add(mWC = new RedirectingMenuItem(p,"Cascade", null));
   mW.add(mWB = new RedirectingMenuItem(p,"Best", null));
   mW.addSeparator();
   mW.add(mWGe = new RedirectingCheckboxMenuItem(p,"Genes", p.mm.MenuActive[0]==1)); 
   mW.add(mWDo = new RedirectingCheckboxMenuItem(p,"Domains", p.mm.MenuActive[1]==1)); 
   mW.add(mWMo = new RedirectingCheckboxMenuItem(p,"Model", p.mm.MenuActive[2]==1)); mWMo.setEnabled(false);
   mW.add(mWOp = new RedirectingCheckboxMenuItem(p,"Operators", p.mm.MenuActive[3]==1)); mWOp.setEnabled(false);
   mW.add(mWEx = new RedirectingCheckboxMenuItem(p,"Expression", p.mm.MenuActive[4]==1)); mWEx.setEnabled(false);
   mW.add(mWDa = new RedirectingCheckboxMenuItem(p,"Data", p.mm.MenuActive[5]==1)); mWDa.setEnabled(false);
   mW.add(mWNa = new RedirectingCheckboxMenuItem(p,"NanoString", p.mm.MenuActive[6]==1));mWNa.setEnabled(false);
   mW.add(mWCom = new RedirectingCheckboxMenuItem(p,"Compare", p.mm.MenuActive[7]==1)); mWCom.setEnabled(false);
   mW.add(mWTr = new RedirectingCheckboxMenuItem(p,"Tree", p.mm.MenuActive[8]==1)); 

        
  p.frame.setMenuBar(mb);
}
 
开发者ID:EmmanuelFaure76,项目名称:GeNeTool,代码行数:43,代码来源:MenuBarManager.java

示例12: Application

import java.awt.MenuBar; //导入方法依赖的package包/类
Application() {
	userNameChangeListeners = new LinkedList<UserNameChangeListener>();

	chatList = new LinkedList<String>();
	setSize(800, 600);
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
	
	userList = new LinkedList<User>();
	userListModel = new UserListModel();
	JList userListView = new JList(userListModel);
	
	MenuBar menuBar = new MenuBar();
	Menu menuSettings = new Menu("Settings");
	MenuItem menuUserSettings = new MenuItem("Open user settings");
	menuUserSettings.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			UserSettings.showSettings();
		}
	});
	menuSettings.add(menuUserSettings);
	menuBar.add(menuSettings);
	setMenuBar(menuBar);

	new JScrollPane(userListView);

	JPanel centerView = new JPanel();
	centerView.setLayout(new BoxLayout(centerView, BoxLayout.Y_AXIS));

	chatListModel = new ChatListModel();
	chatListView = new JList(chatListModel);
	listViewPanel = new JScrollPane(chatListView);
	/* listViewPanel.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
        public void adjustmentValueChanged(AdjustmentEvent e) {
        	if (autoscroll_)
        		e.getAdjustable().setValue(e.getAdjustable().getMaximum());
        }
    }); */
	centerView.add(listViewPanel);
	SendView sendView = new SendView();
	centerView.add(sendView);

	JSplitPane splitView = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, userListView, centerView);
	splitView.setDividerLocation(150);
	add(splitView);
	client = new Client();
	clientThread = new Thread(client);
	clientThread.start();
}
 
开发者ID:0x17de,项目名称:ChatClient,代码行数:51,代码来源:Application.java

示例13: addMenu

import java.awt.MenuBar; //导入方法依赖的package包/类
/**
 * Method declaration
 *
 *
 * @param b
 * @param name
 * @param items
 */
void addMenu(MenuBar b, String name, String items[]) {

    Menu menu = new Menu(name);

    addMenuItems(menu, items);
    b.add(menu);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:DatabaseManager.java

示例14: AppletFrame

import java.awt.MenuBar; //导入方法依赖的package包/类
public AppletFrame(String title, 
     Applet applet_, 
     int width, int height) {
  super("applet", title);
  addWindowListener(this);
  applet = applet_;
  
  MenuBar  menubar = new MenuBar();
  Menu     file    = new Menu("File", true);
  MenuItem quit    = new MenuItem("Quit", new MenuShortcut(KeyEvent.VK_Q));

  setBackground(Color.lightGray);

  quit.addActionListener(this);
  
  menubar.add(file);
  file.add(quit);
  setMenuBar(menubar);
  
  add("Center", applet);

  setSize(width, height);

  applet.init();

  setVisible(true);
  
  validate();

  applet.active = true;
  applet.start();

  validate();
}
 
开发者ID:tamirhassan,项目名称:pdfxtk,代码行数:35,代码来源:AppletFrame.java


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