本文整理匯總了Java中java.awt.PopupMenu.addSeparator方法的典型用法代碼示例。如果您正苦於以下問題:Java PopupMenu.addSeparator方法的具體用法?Java PopupMenu.addSeparator怎麽用?Java PopupMenu.addSeparator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.PopupMenu
的用法示例。
在下文中一共展示了PopupMenu.addSeparator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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.");
}
}
示例2: 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.");
}
}
示例3: 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;
}
示例4: 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);
}
}
示例5: 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;
}
示例6: createPopupMenu
import java.awt.PopupMenu; //導入方法依賴的package包/類
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;
}
示例7: TrayApplication
import java.awt.PopupMenu; //導入方法依賴的package包/類
public TrayApplication(String args[])
{
if (!SystemTray.isSupported())
{
log.severe("\bTrayIcon is not supported, unable to run Scorekeeper monitor application.");
System.exit(-1);
}
if (!ensureSingleton())
{
log.warning("Another TrayApplication is running, quitting now.");
System.exit(-1);
}
actions = new Actions();
state = new StateControl();
statuswindow = new ScorekeeperStatusWindow(actions);
PopupMenu trayPopup = new PopupMenu();
trayPopup.add(new WrappedAWTMenuItem(actions.openStatus));
trayPopup.addSeparator();
for (Action a : actions.apps)
trayPopup.add(new WrappedAWTMenuItem(a));
trayPopup.addSeparator();
trayPopup.add(new WrappedAWTMenuItem(actions.quit));
trayIcon = new TrayIcon(conewarn, "Scorekeeper Monitor", trayPopup);
trayIcon.setImageAutoSize(true);
Messenger.register(MT.BACKEND_READY, (type, data) -> trayIcon.setImage(((boolean)data) ? coneok : conewarn));
try {
SystemTray.getSystemTray().add(trayIcon);
} catch (AWTException e) {
log.severe("\bFailed to create TrayIcon: " + e);
System.exit(-2);
}
statuswindow.setVisible(true);
}
示例8: createComponents
import java.awt.PopupMenu; //導入方法依賴的package包/類
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);
}
示例9: createComponents
import java.awt.PopupMenu; //導入方法依賴的package包/類
private void createComponents() {
startedImage = createImage("/images/futuresonic-started-16.png");
stoppedImage = createImage("/images/futuresonic-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, "FutureSonic Music Streamer", menu);
}
示例10: createComponents
import java.awt.PopupMenu; //導入方法依賴的package包/類
private void createComponents() {
startedImage = createImage("/images/madsonic-started-16.png");
stoppedImage = createImage("/images/madsonic-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, "Madsonic Music Streamer", menu);
}
示例11: getTrayMenu
import java.awt.PopupMenu; //導入方法依賴的package包/類
public PopupMenu getTrayMenu(){
final PopupMenu menu = new PopupMenu();
menu.addSeparator();
menu.add($(EXIT).toAWTMenu());
return menu;
}
示例12: create
import java.awt.PopupMenu; //導入方法依賴的package包/類
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;
}
示例13: initialize
import java.awt.PopupMenu; //導入方法依賴的package包/類
/**
* Initializes this tray manager object and creates the tray icon and its
* context menu.
*
* @throws UnsupportedSystemTrayException
* If the current platform does not support a system tray.
*/
private final void initialize() throws UnsupportedSystemTrayException {
this.logger.logInfo("Initializing TrayManager.");
if (!SystemTray.isSupported()) {
throw new UnsupportedSystemTrayException();
}
this.systemTray = SystemTray.getSystemTray();
this.trayIcon = new TrayIcon(this.trayIconImage, TRAY_NAME);
this.trayIcon.setImageAutoSize(true);
final MenuItem forceCacheUpdate = new MenuItem(FORCE_CACHE_UPDATE_NAME);
final MenuItem toggleDebugWindow = new MenuItem(TOGGLE_DEBUG_WINDOW_NAME);
final MenuItem setApiKey = new MenuItem(SET_API_KEY_NAME);
final MenuItem setRegion = new MenuItem(SET_REGION_NAME);
final MenuItem setSummonername = new MenuItem(SET_SUMMONER_NAME);
final MenuItem exit = new MenuItem(EXIT);
final MenuItem findMatch = new MenuItem(FIND_MATCH_NAME);
final PopupMenu popup = new PopupMenu();
popup.add(forceCacheUpdate);
popup.add(toggleDebugWindow);
popup.addSeparator();
popup.add(setApiKey);
popup.add(setRegion);
popup.add(setSummonername);
popup.addSeparator();
popup.add(findMatch);
popup.add(exit);
this.trayIcon.setPopupMenu(popup);
exit.addActionListener(new ExitListener(this.leagueStats));
toggleDebugWindow.addActionListener(new ToggleDebugWindowListener(this.leagueStats));
setApiKey.addActionListener(new SetApiKeyListener(this.leagueStats));
setRegion.addActionListener(new SetRegionListener(this.leagueStats));
setSummonername.addActionListener(new SetSummonerNameListener(this.leagueStats));
forceCacheUpdate.addActionListener(new ResetCacheListener(this.leagueStats));
findMatch.addActionListener(new FindMatchListener(this.leagueStats));
}
示例14: installTrayIcon
import java.awt.PopupMenu; //導入方法依賴的package包/類
/**
* 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 );
}
}
示例15: SystemTrayHandler
import java.awt.PopupMenu; //導入方法依賴的package包/類
public SystemTrayHandler(PluginHandler plugin, String working_directory, AudioInput in)
{
this.plugin = plugin;
this.in = in;
this.plugins_directory = working_directory + "Plugins/";
// Okay, this one was stupid hacky. I couldn't figure out how to export
// images with processing, but I noticed that in
// Processing.app/Contents/Java/ there was a file named jssc.txt.
// I'm almost 100% certain that Processing isn't using this. So I found
// the file in /Applications/Processing.app/Contents/Java/modes/java/libraries/serial/library/jssc.txt
// I took my icon.gif and renamed it to jssc.txt, and it appears to work.
String icon = SystemTrayHandler.class.getResource("").getPath() + "jssc.txt";
if ( SystemTray.isSupported() )
{
if ( !( new File( icon ) ).exists() )
{
String local_icon = working_directory + "icon.gif";
if ( !( new File( local_icon ) ).exists() )
{
Message.showError(
"Could not find icon.gif to put in the System Tray. We looked in<br />"+
icon +
"<br />and<br />" +
local_icon +
"<br /><br />The program will now exit.",
"ICON_NOT_FOUND" );
System.exit(1);
}
icon = local_icon;
}
final PopupMenu popup = new PopupMenu();
final Image image = Toolkit.getDefaultToolkit()
.getImage( icon );
final TrayIcon trayIcon = new TrayIcon( image, "Light Controller" );
final SystemTray tray = SystemTray.getSystemTray();
addPluginsMenu( popup );
popup.addSeparator();
if(!MIXER_BUG) addAudioMenu( popup );
addSettingsMenu( popup );
popup.addSeparator();
addExitItem( popup );
trayIcon.setPopupMenu( popup );
try
{
tray.add( trayIcon );
}
catch ( AWTException e )
{
Message.showError(
"There was a problem creating an icon on the system tray.<br />"+
"The program will now exit.<br />"+
"Below you will find the stack trace for this error.\n",
"AWTException_CREATING_ICON", e );
System.exit(1);
}
}
else
{
Message.showError(
"Light Controller is not supported on this machine<br />"+
"due to system tray being unsupported.<br />"+
"The program will now exit.", "NO_SYS_TRAY" );
System.exit(1);
}
}