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