private static Menu initProjectMenu() {
Menu mnProject = new Menu(Resources.get("menu_project"));
CheckboxMenuItem compress = new CheckboxMenuItem(Resources.get("menu_compressProjectFile"));
compress.setState(userPreferences.isCompressFile());
compress.addItemListener(e -> userPreferences.setCompressFile(compress.getState()));
CheckboxMenuItem sync = new CheckboxMenuItem(Resources.get("menu_syncMaps"));
sync.setState(userPreferences.isSyncMaps());
sync.addItemListener(e -> userPreferences.setSyncMaps(sync.getState()));
MenuItem importSpriteFile = new MenuItem(Resources.get("menu_assets_importSpriteFile"));
importSpriteFile.addActionListener(a -> EditorScreen.instance().importSpriteFile());
MenuItem importSprite = new MenuItem(Resources.get("menu_assets_importSprite"));
importSprite.addActionListener(a -> EditorScreen.instance().importSprites());
mnProject.add(importSprite);
mnProject.add(importSpriteFile);
mnProject.addSeparator();
mnProject.add(compress);
mnProject.add(sync);
return mnProject;
}
java类java.awt.MenuItem的实例源码
Program.java 文件源码
项目:litiengine
阅读 28
收藏 0
点赞 0
评论 0
Program.java 文件源码
项目:litiengine
阅读 26
收藏 0
点赞 0
评论 0
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);
}
}
}
SystemTraySupportTest.java 文件源码
项目:EasyFXML
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void register_system_tray_icon() throws ExecutionException, InterruptedException {
final SystemTraySupport systemTraySupport = this.applicationContext.getBean(SystemTraySupport.class);
final MenuItem testItem = new MenuItem("DISABLED_ON_CLICK");
final ActionListener disableOnClick = e -> testItem.setEnabled(false);
final Map<MenuItem, ActionListener> menuItems = new HashMap<MenuItem, ActionListener>() {{
this.put(testItem, disableOnClick);
}};
final SystemTrayIcon trayIcon = this.systemTrayIconWith(menuItems);
systemTraySupport.registerTrayIcon(trayIcon)
.whenCompleteAsync((res, err) -> assertThat(res.isSuccess()).isTrue())
.thenApply(Try::get)
.whenCompleteAsync((res, err) -> assertThat(systemTraySupport.getTrayIcons()).containsExactly(res))
.whenCompleteAsync((res, err) -> systemTraySupport.removeTrayIcon(res))
.thenAccept(icon -> assertThat(systemTraySupport.getTrayIcons()).doesNotContain(icon))
.toCompletableFuture().get();
}
SystemTraySupportTest.java 文件源码
项目:EasyFXML
阅读 24
收藏 0
点赞 0
评论 0
private SystemTrayIcon systemTrayIconWith(final Map<MenuItem, ActionListener> menuItems) {
return new SystemTrayIcon() {
@Override
public String getLabel() {
return TRAY_LABEL;
}
@Override
public URL getIcon() {
return TRAY_ICON_URL;
}
@Override
public Map<MenuItem, ActionListener> getMenuItems() {
return menuItems;
}
};
}
DatabaseManager.java 文件源码
项目:OpenDiabetes
阅读 23
收藏 0
点赞 0
评论 0
private void addToRecent(String s) {
for (int i = 0; i < iMaxRecent; i++) {
if (s.equals(sRecent[i])) {
return;
}
}
if (sRecent[iRecent] != null) {
mRecent.remove(iRecent);
}
sRecent[iRecent] = s;
if (s.length() > 43) {
s = s.substring(0, 40) + "...";
}
MenuItem item = new MenuItem(s);
item.setActionCommand("#" + iRecent);
item.addActionListener(this);
mRecent.insert(item, iRecent);
iRecent = (iRecent + 1) % iMaxRecent;
}
DatabaseManager.java 文件源码
项目:sstore-soft
阅读 39
收藏 0
点赞 0
评论 0
private void addToRecent(String s) {
for (int i = 0; i < iMaxRecent; i++) {
if (s.equals(sRecent[i])) {
return;
}
}
if (sRecent[iRecent] != null) {
mRecent.remove(iRecent);
}
sRecent[iRecent] = s;
if (s.length() > 43) {
s = s.substring(0, 40) + "...";
}
MenuItem item = new MenuItem(s);
item.setActionCommand("#" + iRecent);
item.addActionListener(this);
mRecent.insert(item, iRecent);
iRecent = (iRecent + 1) % iMaxRecent;
}
DatabaseManager.java 文件源码
项目:s-store
阅读 24
收藏 0
点赞 0
评论 0
private void addToRecent(String s) {
for (int i = 0; i < iMaxRecent; i++) {
if (s.equals(sRecent[i])) {
return;
}
}
if (sRecent[iRecent] != null) {
mRecent.remove(iRecent);
}
sRecent[iRecent] = s;
if (s.length() > 43) {
s = s.substring(0, 40) + "...";
}
MenuItem item = new MenuItem(s);
item.setActionCommand("#" + iRecent);
item.addActionListener(this);
mRecent.insert(item, iRecent);
iRecent = (iRecent + 1) % iMaxRecent;
}
DatabaseManager.java 文件源码
项目:dev-courses
阅读 24
收藏 0
点赞 0
评论 0
void addMenuItems(Menu f, String[] m) {
for (int i = 0; i < m.length; i++) {
MenuItem item = new MenuItem(m[i].substring(1));
char c = m[i].charAt(0);
if (c != '-') {
item.setShortcut(new MenuShortcut(c));
}
item.addActionListener(this);
f.add(item);
}
}
DatabaseManager.java 文件源码
项目:dev-courses
阅读 25
收藏 0
点赞 0
评论 0
private void addToRecent(String s) {
for (int i = 0; i < iMaxRecent; i++) {
if (s.equals(sRecent[i])) {
return;
}
}
if (sRecent[iRecent] != null) {
mRecent.remove(iRecent);
}
sRecent[iRecent] = s;
if (s.length() > 43) {
s = s.substring(0, 40) + "...";
}
MenuItem item = new MenuItem(s);
item.setActionCommand("#" + iRecent);
item.addActionListener(this);
mRecent.insert(item, iRecent);
iRecent = (iRecent + 1) % iMaxRecent;
}
DatabaseManager.java 文件源码
项目:parabuild-ci
阅读 25
收藏 0
点赞 0
评论 0
private void addToRecent(String s) {
for (int i = 0; i < iMaxRecent; i++) {
if (s.equals(sRecent[i])) {
return;
}
}
if (sRecent[iRecent] != null) {
mRecent.remove(iRecent);
}
sRecent[iRecent] = s;
if (s.length() > 43) {
s = s.substring(0, 40) + "...";
}
MenuItem item = new MenuItem(s);
item.setActionCommand("#" + iRecent);
item.addActionListener(this);
mRecent.insert(item, iRecent);
iRecent = (iRecent + 1) % iMaxRecent;
}
DatabaseManager.java 文件源码
项目:parabuild-ci
阅读 31
收藏 0
点赞 0
评论 0
private void addToRecent(String s) {
for (int i = 0; i < iMaxRecent; i++) {
if (s.equals(sRecent[i])) {
return;
}
}
if (sRecent[iRecent] != null) {
mRecent.remove(iRecent);
}
sRecent[iRecent] = s;
if (s.length() > 43) {
s = s.substring(0, 40) + "...";
}
MenuItem item = new MenuItem(s);
item.setActionCommand("#" + iRecent);
item.addActionListener(this);
mRecent.insert(item, iRecent);
iRecent = (iRecent + 1) % iMaxRecent;
}
UpdatePopupMenu.java 文件源码
项目:openjdk-jdk10
阅读 18
收藏 0
点赞 0
评论 0
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;
}
UpdatePopupMenu.java 文件源码
项目:openjdk9
阅读 22
收藏 0
点赞 0
评论 0
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;
}
TimeTray.java 文件源码
项目:timetray
阅读 20
收藏 0
点赞 0
评论 0
/**
* 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;
}
MasterFrameMenu.java 文件源码
项目:Tingeltangel
阅读 31
收藏 0
点赞 0
评论 0
private static MenuItem generateMenuItem(TreeElement element) {
if(element.isLeaf()) {
MenuItem item = new MenuItem(element.getCaption());
item.addActionListener(new MasterFrameMenu(element.getFullID()));
if(element.isHidden()) {
item.setEnabled(false);
} else if(!element.getEnabled()) {
item.setEnabled(false);
}
items.put(element.getFullID(), item);
return(item);
} else {
Menu menu = new Menu(element.getCaption());
Iterator<TreeElement> i = element.getChilds();
while(i.hasNext()) {
menu.add(generateMenuItem(i.next()));
}
if(element.isHidden()) {
menu.setEnabled(false);
}
items.put(element.getFullID(), menu);
return(menu);
}
}
DatabaseManager.java 文件源码
项目:VoltDB
阅读 20
收藏 0
点赞 0
评论 0
private void addToRecent(String s) {
for (int i = 0; i < iMaxRecent; i++) {
if (s.equals(sRecent[i])) {
return;
}
}
if (sRecent[iRecent] != null) {
mRecent.remove(iRecent);
}
sRecent[iRecent] = s;
if (s.length() > 43) {
s = s.substring(0, 40) + "...";
}
MenuItem item = new MenuItem(s);
item.setActionCommand("#" + iRecent);
item.addActionListener(this);
mRecent.insert(item, iRecent);
iRecent = (iRecent + 1) % iMaxRecent;
}
Transfer.java 文件源码
项目:VoltDB
阅读 26
收藏 0
点赞 0
评论 0
/**
* Method declaration
*
*
* @param f
* @param m
*/
private void addMenuItems(Menu f, String[] m) {
for (int i = 0; i < m.length; i++) {
if (m[i].equals("-")) {
f.addSeparator();
} else {
MenuItem item = new MenuItem(m[i]);
item.addActionListener(this);
f.add(item);
}
}
}
SimpleUI.java 文件源码
项目:deskshare-public
阅读 22
收藏 0
点赞 0
评论 0
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;
}
SystemTrayHandler.java 文件源码
项目:Processing-Arduino-Light-Controller
阅读 22
收藏 0
点赞 0
评论 0
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 );
}
JStickyNotes.java 文件源码
项目:Desktop
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void actionPerformed(ActionEvent e) {
String label = ((MenuItem) e.getSource()).getLabel();
if (CREATE_NOTE_TEXT.equals(label)) {
createNote();
} else if (SHOW_ALL_NOTES_TEXT.equals(label)) {
showNotes(ALL);
} else if (HIDE_ALL_NOTES_TEXT.equals(label)) {
showNotes(NONE);
} else if (PREFERENCES_TEXT.equals(label)) {
new PreferencesDialog(frame, preferencesManager.getPreferences()).setVisible(true);
} else if (ABOUT_TEXT.equals(label)) {
JLabel about = new JLabel(ABOUT_DIALOG_TEXT);
about.setIcon(Icon.getJStickyNotesImageIcon(48));
JOptionPane.showMessageDialog(frame, about, ABOUT_DIALOG_TITLE_TEXT, JOptionPane.PLAIN_MESSAGE);
} else if (EXIT_TEXT.equals(label)) {
System.exit(0);
}
}
ContextMenu.java 文件源码
项目:openblocks
阅读 24
收藏 0
点赞 0
评论 0
/**
* Initializes the context menu for adding Comments.
*/
private static void initAddCommentMenu() {
ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");
addCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.add_comment"));
addCommentItem.setActionCommand(ADD_COMMENT_BLOCK);
addCommentItem.addActionListener(rndBlockMenu);
addCommentMenu.add(addCommentItem);
cloneItem1 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
cloneItem1.setActionCommand(CLONE_BLOCK);
cloneItem1.addActionListener(rndBlockMenu);
addCommentMenu.add(cloneItem1);
addCommentMenuInit = true;
}
ContextMenu.java 文件源码
项目:openblocks
阅读 24
收藏 0
点赞 0
评论 0
/**
* Initializes the context menu for deleting Comments.
*/
private static void initRemoveCommentMenu() {
ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");
removeCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.delete_comment"));
removeCommentItem.setActionCommand(REMOVE_COMMENT_BLOCK);
removeCommentItem.addActionListener(rndBlockMenu);
removeCommentMenu.add(removeCommentItem);
//rndBlockMenu.add(runBlockItem);
cloneItem2 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
cloneItem2.setActionCommand(CLONE_BLOCK);
cloneItem2.addActionListener(rndBlockMenu);
removeCommentMenu.add(cloneItem2);
removeCommentMenuInit = true;
}
LangToolMain.java 文件源码
项目:oStorybook
阅读 22
收藏 0
点赞 0
评论 0
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;
}
ContextMenu.java 文件源码
项目:Ardublock-for-Dwenguino
阅读 24
收藏 0
点赞 0
评论 0
/**
* Initializes the context menu for adding Comments.
*/
private static void initAddCommentMenu() {
ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");
addCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.add_comment"));
addCommentItem.setActionCommand(ADD_COMMENT_BLOCK);
addCommentItem.addActionListener(rndBlockMenu);
addCommentMenu.add(addCommentItem);
cloneItem1 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
cloneItem1.setActionCommand(CLONE_BLOCK);
cloneItem1.addActionListener(rndBlockMenu);
addCommentMenu.add(cloneItem1);
addCommentMenuInit = true;
}
ContextMenu.java 文件源码
项目:Ardublock-for-Dwenguino
阅读 21
收藏 0
点赞 0
评论 0
/**
* Initializes the context menu for deleting Comments.
*/
private static void initRemoveCommentMenu() {
ResourceBundle uiMessageBundle = ResourceBundle.getBundle("com/ardublock/block/ardublock");
removeCommentItem = new MenuItem(uiMessageBundle.getString("ardublock.ui.delete_comment"));
removeCommentItem.setActionCommand(REMOVE_COMMENT_BLOCK);
removeCommentItem.addActionListener(rndBlockMenu);
removeCommentMenu.add(removeCommentItem);
//rndBlockMenu.add(runBlockItem);
cloneItem2 = new MenuItem(uiMessageBundle.getString("ardublock.ui.clone"));
cloneItem2.setActionCommand(CLONE_BLOCK);
cloneItem2.addActionListener(rndBlockMenu);
removeCommentMenu.add(cloneItem2);
removeCommentMenuInit = true;
}
LangToolMain.java 文件源码
项目:SE-410-Project
阅读 22
收藏 0
点赞 0
评论 0
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;
}
AWTExample.java 文件源码
项目:wwwa
阅读 19
收藏 0
点赞 0
评论 0
public static void main(String[] args) {
Container container = new Container();
Panel panel = new Panel();
Menu menu = new Menu(); //!!! its not component
TextField textField = new TextField();
container.add(textField);
Window win = new Window(null);
win.pack();
menu.setShortcut(new MenuShortcut(12));
new MenuItem("label", new MenuShortcut(33, true));
Menu file = new Menu("File");
MenuItem print;
file.add(print = new MenuItem("Print", new MenuShortcut('p')));
}
SwingSystemMenu.java 文件源码
项目:loli.io
阅读 22
收藏 0
点赞 0
评论 0
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;
}
DatabaseManager.java 文件源码
项目:Pegasus
阅读 20
收藏 0
点赞 0
评论 0
private void addToRecent(String s) {
for (int i = 0; i < iMaxRecent; i++) {
if (s.equals(sRecent[i])) {
return;
}
}
if (sRecent[iRecent] != null) {
mRecent.remove(iRecent);
}
sRecent[iRecent] = s;
if (s.length() > 43) {
s = s.substring(0, 40) + "...";
}
MenuItem item = new MenuItem(s);
item.setActionCommand("#" + iRecent);
item.addActionListener(this);
mRecent.insert(item, iRecent);
iRecent = (iRecent + 1) % iMaxRecent;
}
IconeTaches.java 文件源码
项目:Sources-Jeu
阅读 18
收藏 0
点赞 0
评论 0
private IconeTaches() {
super(Images.get("divers/icone.png", true), TITRE);
setImageAutoSize(true);
setPopupMenu(menu = new PopupMenu("Menu"));
menu.add(quitter = new MenuItem("Quitter"));
menu.add(infos = new MenuItem("A propos..."));
menu.add(admin = new MenuItem("Administrer"));
menu.addSeparator();
menu.add(d3d = new MenuItem("Dessin 3D"));
menu.add(d2d = new MenuItem("Dessin 2D"));
quitter.addActionListener(this);
infos.addActionListener(this);
admin.addActionListener(this);
d3d.addActionListener(this);
d2d.addActionListener(this);
if(SystemTray.isSupported()) try {
SystemTray.getSystemTray().add(this);
} catch(AWTException e) {
e.printStackTrace();
}
}