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


Java PopupMenu.add方法代碼示例

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


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

示例1: initSystemTray

import java.awt.PopupMenu; //導入方法依賴的package包/類
private static void initSystemTray() {
  // add system tray icon with popup menu
  if (SystemTray.isSupported()) {
    SystemTray tray = SystemTray.getSystemTray();
    PopupMenu menu = new PopupMenu();
    MenuItem exitItem = new MenuItem(Resources.get("menu_exit"));
    exitItem.addActionListener(a -> Game.terminate());
    menu.add(exitItem);

    trayIcon = new TrayIcon(RenderEngine.getImage("pixel-icon-utility.png"), Game.getInfo().toString(), menu);
    trayIcon.setImageAutoSize(true);
    try {
      tray.add(trayIcon);
    } catch (AWTException e) {
      log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
  }
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:19,代碼來源:Program.java

示例2: createPopupMenu

import java.awt.PopupMenu; //導入方法依賴的package包/類
private PopupMenu createPopupMenu(final TrayIcon trayIcon,
        final int menuCount) {

    final PopupMenu trayIconPopupMenu = new PopupMenu();

    for (int i = 1; i <= menuCount; ++i) {
        final MenuItem popupMenuItem = new MenuItem("MenuItem_" + i);

        popupMenuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
                trayIcon.setPopupMenu(createPopupMenu(trayIcon,
                        menuCount + 1));
            }
        });

        trayIconPopupMenu.add(popupMenuItem);
    }

    return trayIconPopupMenu;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:UpdatePopupMenu.java

示例3: createMenu

import java.awt.PopupMenu; //導入方法依賴的package包/類
/**
 * creates a PopUp menu for the TrayIcon
 *
 * @return PopUp menu for the TrayIcon
 */
private PopupMenu createMenu() {
    PopupMenu menu = new PopupMenu("TimeTray " + this.VERSION);

    // about item
    MenuItem menuSettings = new MenuItem("Settings");
    menuSettings.setActionCommand("settings");
    menu.add(menuSettings);

    // exit item
    MenuItem menuExit = new MenuItem("Quit");
    menuExit.setActionCommand("quit");
    menu.add(menuExit);

    menu.addActionListener(this);

    return menu;
}
 
開發者ID:otacke,項目名稱:timetray,代碼行數:23,代碼來源:TimeTray.java

示例4: createPopupMenu

import java.awt.PopupMenu; //導入方法依賴的package包/類
private PopupMenu createPopupMenu() {
	final PopupMenu popup = new PopupMenu();
	if (allowScreenSwitch) {
		MenuItem switchItem = new MenuItem(Main.getString("text.switchscreen"));
		switchItem.setActionCommand("switch");
		switchItem.addActionListener(this);
		// add to popup
		popup.add(switchItem);
	}
	MenuItem exitItem = new MenuItem(Main.getString("text.exit"));
	exitItem.setActionCommand("exit");
	exitItem.addActionListener(this);
	// add to pop-up menu
	popup.add(exitItem);
	return popup;
}
 
開發者ID:BigMarker,項目名稱:deskshare-public,代碼行數:17,代碼來源:SimpleUI.java

示例5: addExitItem

import java.awt.PopupMenu; //導入方法依賴的package包/類
private void addExitItem( PopupMenu popup )
{
    MenuItem exit = new MenuItem( "Exit" );
    exit.addActionListener( new ActionListener()
    {
        @Override
        public void actionPerformed( ActionEvent e )
        {
            // Exits the program
            // plugin.resetLeds();
            // TODO: Decide whether or not LEDS should turn off when
            // program exits.
            //      Pros: You can set a color and then quit the program
            //      Cons: For LEDS to turn off, user has to unload plugins
            System.exit(0);
        }
    });
    popup.add( exit );
}
 
開發者ID:uPaymeiFixit,項目名稱:Processing-Arduino-Light-Controller,代碼行數:20,代碼來源:SystemTrayHandler.java

示例6: makePopupMenu

import java.awt.PopupMenu; //導入方法依賴的package包/類
private PopupMenu makePopupMenu() {
	final PopupMenu popup = new PopupMenu();
	final ActionListener rmbListener = new TrayActionRMBListener();
	// Check clipboard text:
	final MenuItem checkClipboardItem = new MenuItem(
			StringTools.getLabel(messages
					.getString("guiMenuCheckClipboard")));
	checkClipboardItem.addActionListener(rmbListener);
	popup.add(checkClipboardItem);
	// Open main window:
	final MenuItem restoreItem = new MenuItem(StringTools.getLabel(messages
			.getString("guiMenuShowMainWindow")));
	restoreItem.addActionListener(rmbListener);
	popup.add(restoreItem);
	// Exit:
	final MenuItem exitItem = new MenuItem(StringTools.getLabel(messages
			.getString("guiMenuQuit")));
	exitItem.addActionListener(rmbListener);
	popup.add(exitItem);
	return popup;
}
 
開發者ID:markkohdev,項目名稱:oStorybook,代碼行數:22,代碼來源:LangToolMain.java

示例7: generateMenu

import java.awt.PopupMenu; //導入方法依賴的package包/類
private PopupMenu generateMenu() {
    // 創建彈出菜單
    PopupMenu popup = new PopupMenu();
    // 以下將各個菜單項加入到彈出菜單中
    MenuItem full = new MenuItem("全屏截圖");
    full.addActionListener(listener);
    popup.add(full);
    MenuItem select = new MenuItem("選擇截圖");
    select.addActionListener(listener);
    popup.add(select);
    MenuItem settings = new MenuItem("設置");
    settings.addActionListener(listener);
    popup.add(settings);
    MenuItem quit = new MenuItem("退出");
    quit.addActionListener(listener);
    popup.add(quit);
    return popup;
}
 
開發者ID:mba811,項目名稱:loli.io,代碼行數:19,代碼來源:SwingSystemMenu.java

示例8: createComponents

import java.awt.PopupMenu; //導入方法依賴的package包/類
private void createComponents() {
    PopupMenu menu = new PopupMenu();
    menu.add(createMenuItem(openAction));
    menu.add(createMenuItem(controlPanelAction));
    menu.addSeparator();
    menu.add(createMenuItem(quitAction));

    URL url = getClass().getResource("/images/futuresonic-21.png");
    Image image = Toolkit.getDefaultToolkit().createImage(url);
    TrayIcon trayIcon = new TrayIcon(image, "FutureSonic Music Streamer", menu);
    trayIcon.setImageAutoSize(false);

    try {
        SystemTray.getSystemTray().add(trayIcon);
    } catch (Throwable x) {
        System.err.println("Failed to add tray icon.");
    }
}
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:19,代碼來源:SubsonicController.java

示例9: createComponents

import java.awt.PopupMenu; //導入方法依賴的package包/類
private void createComponents() {
    PopupMenu menu = new PopupMenu();
    menu.add(createMenuItem(openAction));
    menu.add(createMenuItem(controlPanelAction));
    menu.addSeparator();
    menu.add(createMenuItem(quitAction));

    URL url = getClass().getResource("/images/madsonic-21.png");
    Image image = Toolkit.getDefaultToolkit().createImage(url);
    TrayIcon trayIcon = new TrayIcon(image, "Madsonic Music Streamer", menu);
    trayIcon.setImageAutoSize(false);

    try {
        SystemTray.getSystemTray().add(trayIcon);
    } catch (Throwable x) {
        System.err.println("Failed to add tray icon.");
    }
}
 
開發者ID:MadMarty,項目名稱:madsonic-server-5.1,代碼行數:19,代碼來源:MadsonicController.java

示例10: createPopupMenu

import java.awt.PopupMenu; //導入方法依賴的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

示例11: StaveActionHandler

import java.awt.PopupMenu; //導入方法依賴的package包/類
StaveActionHandler(Stave stave) {
theApp = stave;

      noteContextMenu = new PopupMenu();
      
      editNote = new MenuItem("Edit Note");
      editNote.addActionListener(this);
      noteContextMenu.add(editNote );       
      
      repeatNote = new MenuItem("Repeat Note");
      repeatNote.addActionListener(this);
      noteContextMenu.add(repeatNote ); 		
      
      makeRest = new MenuItem("Change to Rest");
      makeRest.addActionListener(this);
      noteContextMenu.add(makeRest);       
      
      deleteNote = new MenuItem("Delete Note");
      deleteNote.addActionListener(this);
      noteContextMenu.add(deleteNote );       
      
      theApp.add(noteContextMenu);
  }
 
開發者ID:Armaxis,項目名稱:jmg,代碼行數:24,代碼來源:StaveActionHandler.java

示例12: SysTrayIcon

import java.awt.PopupMenu; //導入方法依賴的package包/類
public SysTrayIcon(JDesktopAgent frame, String tooltip) {
    Translate translate = Translate.getTranslate();
    if (SystemTray.isSupported()) {
        Image image = Toolkit.getDefaultToolkit().getImage("icon.png");

        PopupMenu popup = new PopupMenu();
        popup.add(new RestoreMenuItem(frame, translate.backgroundRestore()));
        popup.addSeparator();
        popup.add(new AboutMenuItem(translate.about()));
        popup.addSeparator();
        popup.add(new ExitMenuItem(translate.exit()));

        TrayIcon trayIcon = new TrayIcon(image, tooltip, popup);
        trayIcon.setImageAutoSize(true);
        trayIcon.addMouseListener(new IconListener(frame));

        try {
            SystemTray.getSystemTray().add(trayIcon);
        } catch (AWTException e) {
            new SysTrayForm(frame).setVisible(true);
        }
    } else {
        new SysTrayForm(frame).setVisible(true);
    }

}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:27,代碼來源:SysTrayIcon.java

示例13: buildTrayIcon

import java.awt.PopupMenu; //導入方法依賴的package包/類
public TrayIcon buildTrayIcon() throws IOException {
    PopupMenu popup = new PopupMenu();
    for (MenuItemDefinition mid : menuItems) {
        if (mid instanceof SeperatorMenuItem) {
            popup.addSeparator();
        } else {
            MenuItem item = new MenuItem();
            item.setLabel(mid.getText());
            item.addActionListener(mid);
            popup.add(item);
        }
    }

    TrayIcon ti = new TrayIcon(getImage(imageName), tooltip, popup);
    ti.setImageAutoSize(true);
    return ti;
}
 
開發者ID:devbury,項目名稱:mkRemote,代碼行數:18,代碼來源:TrayIconDefinition.java

示例14: makePopupMenu

import java.awt.PopupMenu; //導入方法依賴的package包/類
private PopupMenu makePopupMenu() {
  PopupMenu popup = new PopupMenu();
  ActionListener rmbListener = new TrayActionRMBListener();
  // Enable or disable embedded HTTP server:
  enableHttpServerItem = new CheckboxMenuItem(Tools.getLabel(messages.getString("tray_menu_enable_server")));
  enableHttpServerItem.setState(httpServer != null && httpServer.isRunning());
  enableHttpServerItem.addItemListener(new TrayActionItemListener());
  popup.add(enableHttpServerItem);
  // Check clipboard text:
  MenuItem checkClipboardItem =
          new MenuItem(Tools.getLabel(messages.getString("guiMenuCheckClipboard")));
  checkClipboardItem.addActionListener(rmbListener);
  popup.add(checkClipboardItem);
  // Open main window:
  MenuItem restoreItem = new MenuItem(Tools.getLabel(messages.getString("guiMenuShowMainWindow")));
  restoreItem.addActionListener(rmbListener);
  popup.add(restoreItem);
  // Exit:
  MenuItem exitItem = new MenuItem(Tools.getLabel(messages.getString("guiMenuQuit")));
  exitItem.addActionListener(rmbListener);
  popup.add(exitItem);
  return popup;
}
 
開發者ID:languagetool-org,項目名稱:languagetool,代碼行數:24,代碼來源:Main.java

示例15: initialize

import java.awt.PopupMenu; //導入方法依賴的package包/類
/**
 * Intializes the tray manager and creates the tray icon and its context
 * menu.
 * 
 * @throws UnsupportedSystemTrayException
 *             If the current platform does not support a system tray
 */
private void initialize() throws UnsupportedSystemTrayException {
	if (this.mLogger.isDebugEnabled()) {
		this.mLogger.logDebug("Initializing TrayManager");
	}

	// If try is not supported, abort
	if (!SystemTray.isSupported()) {
		throw new UnsupportedSystemTrayException();
	}

	this.mSystemTray = SystemTray.getSystemTray();

	this.mTrayIcon = new TrayIcon(this.mTrayIconImage, NAME_TRAY);
	this.mTrayIcon.setImageAutoSize(true);

	final MenuItem restartItem = new MenuItem(NAME_RESTART);
	final MenuItem exitItem = new MenuItem(NAME_EXIT);

	final PopupMenu popup = new PopupMenu();
	popup.add(restartItem);
	popup.add(exitItem);
	this.mTrayIcon.setPopupMenu(popup);

	restartItem.addActionListener(new RestartListener(this.mParent));
	exitItem.addActionListener(new ExitListener(this.mParent));
}
 
開發者ID:ZabuzaW,項目名稱:BrainBridge,代碼行數:34,代碼來源:TrayManager.java


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