Java Code Examples for java.awt.PopupMenu#addSeparator()
The following examples show how to use
java.awt.PopupMenu#addSeparator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownApplication.java From proxyee-down with Apache License 2.0 | 6 votes |
public void loadPopupMenu() { //添加右键菜单 PopupMenu popupMenu = new PopupMenu(); MenuItem showItem = new MenuItem(I18nUtil.getMessage("gui.tray.show")); showItem.addActionListener(event -> Platform.runLater(() -> loadUri("", true))); MenuItem setItem = new MenuItem(I18nUtil.getMessage("gui.tray.set")); setItem.addActionListener(event -> loadUri("/#/setting", true)); MenuItem aboutItem = new MenuItem(I18nUtil.getMessage("gui.tray.about")); aboutItem.addActionListener(event -> loadUri("/#/about", true)); MenuItem supportItem = new MenuItem(I18nUtil.getMessage("gui.tray.support")); supportItem.addActionListener(event -> loadUri("/#/support", true)); MenuItem closeItem = new MenuItem(I18nUtil.getMessage("gui.tray.exit")); closeItem.addActionListener(event -> { Platform.exit(); System.exit(0); }); popupMenu.add(showItem); popupMenu.addSeparator(); popupMenu.add(setItem); popupMenu.add(aboutItem); popupMenu.add(supportItem); popupMenu.addSeparator(); popupMenu.add(closeItem); trayIcon.setPopupMenu(popupMenu); }
Example 2
Source File: Manager.java From ramus with GNU General Public License v3.0 | 5 votes |
private PopupMenu createPopupMenu() { PopupMenu menu = new PopupMenu(getString("Server") + " " + Metadata.getApplicationName()); menu.add(createStart()); menu.add(createStop()); menu.addSeparator(); menu.add(createRestart()); menu.addSeparator(); menu.add(createPreferences()); menu.addSeparator(); menu.add(createExit()); return menu; }
Example 3
Source File: TrayController.java From subsonic with GNU General Public License v3.0 | 5 votes |
private void createComponents() { startedImage = createImage("/images/subsonic-started-16.png"); stoppedImage = createImage("/images/subsonic-stopped-16.png"); PopupMenu menu = new PopupMenu(); menu.add(createMenuItem(openAction)); menu.add(createMenuItem(controlPanelAction)); menu.addSeparator(); menu.add(createMenuItem(hideAction)); trayIcon = new TrayIcon(stoppedImage, "Subsonic Music Streamer", menu); }
Example 4
Source File: JTrayMenu.java From PeerWasp with MIT License | 5 votes |
public PopupMenu create(boolean isUserLoggedIn) { root = new PopupMenu(); if (isUserLoggedIn) { root.add(createRootFolderMenu()); // root.add(createRecentFilesMenu()); // TODO: implement additional feature. root.addSeparator(); root.add(createSettingsMenu()); root.addSeparator(); } root.add(createActivityMenu()); root.add(createQuitMenu()); return root; }
Example 5
Source File: MainFrame.java From scelight with Apache License 2.0 | 4 votes |
/** * Installs a system tray icon. */ private void installTrayIcon() { if ( !SystemTray.isSupported() ) return; final TrayIcon trayIcon = new TrayIcon( Icons.MY_APP_ICON.get().getImage(), Consts.APP_NAME_FULL + " is running." ); trayIcon.setImageAutoSize( true ); try { SystemTray.getSystemTray().add( trayIcon ); this.trayIcon = trayIcon; trayIcon.addActionListener( Actions.SHOW_MAIN_FRAME ); final PopupMenu popup = new PopupMenu(); final MenuItem restoreMenuItem = new MenuItem( "Show Main Window" ); restoreMenuItem.addActionListener( Actions.SHOW_MAIN_FRAME ); popup.add( restoreMenuItem ); final MenuItem hideMenuItem = new MenuItem( "Hide Main Window" ); hideMenuItem.addActionListener( Actions.MINIMIZE_TO_TRAY ); popup.add( hideMenuItem ); popup.addSeparator(); final MenuItem restoreDefPosMenuItem = new MenuItem( "Restore Main Window to defaults" ); restoreDefPosMenuItem.addActionListener( new ActionAdapter() { @Override public void actionPerformed( final ActionEvent e ) { // First ensure it's visible and active: Actions.SHOW_MAIN_FRAME.actionPerformed( null ); // And the default position: Actions.RESTORE_DEF_WIN_POSITION.actionPerformed( null ); } } ); popup.add( restoreDefPosMenuItem ); popup.addSeparator(); final MenuItem exitMenuItem = new MenuItem( "Exit" ); exitMenuItem.addActionListener( Actions.EXIT ); popup.add( exitMenuItem ); trayIcon.setPopupMenu( popup ); Actions.MINIMIZE_TO_TRAY.setEnabled( true ); } catch ( final AWTException ae ) { Env.LOGGER.debug( "Failed to install tray icon!", ae ); } }