java.awt.MenuItem Java Examples
The following examples show how to use
java.awt.MenuItem.
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: UpdatePopupMenu.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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; }
Example #2
Source File: Manager.java From ramus with GNU General Public License v3.0 | 5 votes |
private MenuItem createPreferences() { MenuItem pItem = new MenuItem(getString("Action.Preferences")); pItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setup(); } }); return pItem; }
Example #3
Source File: Manager.java From ramus with GNU General Public License v3.0 | 5 votes |
private MenuItem createRestart() { restartItem = new MenuItem(getString("Action.Restart")); restartItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { restart(); } }); restartItem.setEnabled(false); return restartItem; }
Example #4
Source File: CMenu.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public final void setEnabled(final boolean b) { super.setEnabled(b); final Menu target = (Menu) getTarget(); final int count = target.getItemCount(); for (int i = 0; i < count; ++i) { MenuItem item = target.getItem(i); MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item); if (p != null) { p.setEnabled(b && item.isEnabled()); } } }
Example #5
Source File: CMenuItem.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void setLabel(String label, char keyChar, int keyCode, int modifiers) { int keyMask = modifiers; if (keyCode == KeyEvent.VK_UNDEFINED) { MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut(); if (shortcut != null) { keyCode = shortcut.getKey(); keyMask |= InputEvent.META_MASK; if (shortcut.usesShiftModifier()) { keyMask |= InputEvent.SHIFT_MASK; } } } if (label == null) { label = ""; } // <rdar://problem/3654824> // Native code uses a keyChar of 0 to indicate that the // keyCode should be used to generate the shortcut. Translate // CHAR_UNDEFINED into 0. if (keyChar == KeyEvent.CHAR_UNDEFINED) { keyChar = 0; } final String finalLabel = label; final char finalKeyChar = keyChar; final int finalKeyCode = keyCode; final int finalKeyMask = keyMask; execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar, finalKeyCode, finalKeyMask)); }
Example #6
Source File: CMenu.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public final void setEnabled(final boolean b) { super.setEnabled(b); final Menu target = (Menu) getTarget(); final int count = target.getItemCount(); for (int i = 0; i < count; ++i) { MenuItem item = target.getItem(i); MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item); if (p != null) { p.setEnabled(b && item.isEnabled()); } } }
Example #7
Source File: CMenuItem.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void setLabel(String label, char keyChar, int keyCode, int modifiers) { int keyMask = modifiers; if (keyCode == KeyEvent.VK_UNDEFINED) { MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut(); if (shortcut != null) { keyCode = shortcut.getKey(); keyMask |= InputEvent.META_MASK; if (shortcut.usesShiftModifier()) { keyMask |= InputEvent.SHIFT_MASK; } } } if (label == null) { label = ""; } // <rdar://problem/3654824> // Native code uses a keyChar of 0 to indicate that the // keyCode should be used to generate the shortcut. Translate // CHAR_UNDEFINED into 0. if (keyChar == KeyEvent.CHAR_UNDEFINED) { keyChar = 0; } final String finalLabel = label; final char finalKeyChar = keyChar; final int finalKeyCode = keyCode; final int finalKeyMask = keyMask; execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar, finalKeyCode, finalKeyMask)); }
Example #8
Source File: CMenuItem.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void setLabel(String label, char keyChar, int keyCode, int modifiers) { int keyMask = modifiers; if (keyCode == KeyEvent.VK_UNDEFINED) { MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut(); if (shortcut != null) { keyCode = shortcut.getKey(); keyMask |= InputEvent.META_MASK; if (shortcut.usesShiftModifier()) { keyMask |= InputEvent.SHIFT_MASK; } } } if (label == null) { label = ""; } // <rdar://problem/3654824> // Native code uses a keyChar of 0 to indicate that the // keyCode should be used to generate the shortcut. Translate // CHAR_UNDEFINED into 0. if (keyChar == KeyEvent.CHAR_UNDEFINED) { keyChar = 0; } final String finalLabel = label; final char finalKeyChar = keyChar; final int finalKeyCode = keyCode; final int finalKeyMask = keyMask; execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar, finalKeyCode, finalKeyMask)); }
Example #9
Source File: CMenuItem.java From hottub with GNU General Public License v2.0 | 5 votes |
public void setLabel(String label, char keyChar, int keyCode, int modifiers) { int keyMask = modifiers; if (keyCode == KeyEvent.VK_UNDEFINED) { MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut(); if (shortcut != null) { keyCode = shortcut.getKey(); keyMask |= InputEvent.META_MASK; if (shortcut.usesShiftModifier()) { keyMask |= InputEvent.SHIFT_MASK; } } } if (label == null) { label = ""; } // <rdar://problem/3654824> // Native code uses a keyChar of 0 to indicate that the // keyCode should be used to generate the shortcut. Translate // CHAR_UNDEFINED into 0. if (keyChar == KeyEvent.CHAR_UNDEFINED) { keyChar = 0; } nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask); }
Example #10
Source File: CMenu.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Override public final void setEnabled(final boolean b) { super.setEnabled(b); final Menu target = (Menu) getTarget(); final int count = target.getItemCount(); for (int i = 0; i < count; ++i) { MenuItem item = target.getItem(i); MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item); if (p != null) { p.setEnabled(b && item.isEnabled()); } } }
Example #11
Source File: Manager.java From ramus with GNU General Public License v3.0 | 5 votes |
private MenuItem createExit() { MenuItem exitItem = new MenuItem(GlobalResourcesManager .getString("Action.Exit")); exitItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exit(); } }); return exitItem; }
Example #12
Source File: CMenuItem.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void setLabel(String label, char keyChar, int keyCode, int modifiers) { int keyMask = modifiers; if (keyCode == KeyEvent.VK_UNDEFINED) { MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut(); if (shortcut != null) { keyCode = shortcut.getKey(); keyMask |= InputEvent.META_MASK; if (shortcut.usesShiftModifier()) { keyMask |= InputEvent.SHIFT_MASK; } } } if (label == null) { label = ""; } // <rdar://problem/3654824> // Native code uses a keyChar of 0 to indicate that the // keyCode should be used to generate the shortcut. Translate // CHAR_UNDEFINED into 0. if (keyChar == KeyEvent.CHAR_UNDEFINED) { keyChar = 0; } final String finalLabel = label; final char finalKeyChar = keyChar; final int finalKeyCode = keyCode; final int finalKeyMask = keyMask; execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar, finalKeyCode, finalKeyMask)); }
Example #13
Source File: CMenuItem.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void handleAction(final long when, final int modifiers) { SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() { public void run() { final String cmd = ((MenuItem)getTarget()).getActionCommand(); final ActionEvent event = new ActionEvent(getTarget(), ActionEvent.ACTION_PERFORMED, cmd, when, modifiers); SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event); } }); }
Example #14
Source File: Launcher.java From Openfire with Apache License 2.0 | 5 votes |
private void toggleVisibility(MenuItem showMenuItem) { // Hide/Unhide the window if the user clicked in the system tray icon or // selected the menu option if (frame.isVisible()) { frame.setVisible(false); showMenuItem.setLabel("Show"); } else { frame.setVisible(true); frame.setState(Frame.NORMAL); showMenuItem.setLabel("Hide"); } }
Example #15
Source File: Transfer.java From evosql with Apache License 2.0 | 5 votes |
/** * 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); } } }
Example #16
Source File: CMenuItem.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void setLabel(String label, char keyChar, int keyCode, int modifiers) { int keyMask = modifiers; if (keyCode == KeyEvent.VK_UNDEFINED) { MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut(); if (shortcut != null) { keyCode = shortcut.getKey(); keyMask |= InputEvent.META_MASK; if (shortcut.usesShiftModifier()) { keyMask |= InputEvent.SHIFT_MASK; } } } if (label == null) { label = ""; } // <rdar://problem/3654824> // Native code uses a keyChar of 0 to indicate that the // keyCode should be used to generate the shortcut. Translate // CHAR_UNDEFINED into 0. if (keyChar == KeyEvent.CHAR_UNDEFINED) { keyChar = 0; } nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask); }
Example #17
Source File: DatabaseManager.java From evosql with Apache License 2.0 | 5 votes |
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); } }
Example #18
Source File: ActionEventTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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(); }
Example #19
Source File: CMenu.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public final void setEnabled(final boolean b) { super.setEnabled(b); final Menu target = (Menu) getTarget(); final int count = target.getItemCount(); for (int i = 0; i < count; ++i) { MenuItem item = target.getItem(i); MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item); if (p != null) { p.setEnabled(b && item.isEnabled()); } } }
Example #20
Source File: CMenuItem.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void setLabel(String label, char keyChar, int keyCode, int modifiers) { int keyMask = modifiers; if (keyCode == KeyEvent.VK_UNDEFINED) { MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut(); if (shortcut != null) { keyCode = shortcut.getKey(); keyMask |= InputEvent.META_MASK; if (shortcut.usesShiftModifier()) { keyMask |= InputEvent.SHIFT_MASK; } } } if (label == null) { label = ""; } // <rdar://problem/3654824> // Native code uses a keyChar of 0 to indicate that the // keyCode should be used to generate the shortcut. Translate // CHAR_UNDEFINED into 0. if (keyChar == KeyEvent.CHAR_UNDEFINED) { keyChar = 0; } nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask); }
Example #21
Source File: CMenu.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public final void setEnabled(final boolean b) { super.setEnabled(b); final Menu target = (Menu) getTarget(); final int count = target.getItemCount(); for (int i = 0; i < count; ++i) { MenuItem item = target.getItem(i); MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item); if (p != null) { p.setEnabled(b && item.isEnabled()); } } }
Example #22
Source File: CMenuItem.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void setLabel(String label, char keyChar, int keyCode, int modifiers) { int keyMask = modifiers; if (keyCode == KeyEvent.VK_UNDEFINED) { MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut(); if (shortcut != null) { keyCode = shortcut.getKey(); keyMask |= InputEvent.META_MASK; if (shortcut.usesShiftModifier()) { keyMask |= InputEvent.SHIFT_MASK; } } } if (label == null) { label = ""; } // <rdar://problem/3654824> // Native code uses a keyChar of 0 to indicate that the // keyCode should be used to generate the shortcut. Translate // CHAR_UNDEFINED into 0. if (keyChar == KeyEvent.CHAR_UNDEFINED) { keyChar = 0; } nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask); }
Example #23
Source File: CMenu.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public final void setEnabled(final boolean b) { super.setEnabled(b); final Menu target = (Menu) getTarget(); final int count = target.getItemCount(); for (int i = 0; i < count; ++i) { MenuItem item = target.getItem(i); MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item); if (p != null) { p.setEnabled(b && item.isEnabled()); } } }
Example #24
Source File: CMenu.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Override public final void addItem(MenuItem item) { // Nothing to do here -- we added it when we created the // menu item's peer. }
Example #25
Source File: CMenuItem.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public CMenuItem(MenuItem target) { super(target); initialize(target); }
Example #26
Source File: AppleDock.java From Spark with Apache License 2.0 | 4 votes |
public AppleDock() { PopupMenu menu = new PopupMenu(); PopupMenu statusmenu = new PopupMenu(Res.getString("menuitem.status")); for (Presence p : PresenceManager.getPresences()) { MenuItem dd = new MenuItem(p.getStatus()); dd.addActionListener(this); statusmenu.add(dd); } menu.add(statusmenu); JFrame frame = SparkManager.getMainWindow(); frame.add(menu); // set dock menu Application app = new Application(); app.setDockMenu(menu); }
Example #27
Source File: GUISample.java From ETL_Unicorn with Apache License 2.0 | 4 votes |
private void CreatMap() throws IOException { w= 1446- 130; h= 820- 110; updateRelatedLine= new UpdateRelatedLineVPS(); getContentPane().setLayout(null); UIManager.put("SplitPaneUI", "org.LYG.GUI.platForm.UnicornSplitPaneUI"); UIManager.put("ScrollBarUI", "org.LYG.GUI.platForm.UnicornScrollBarUI"); UIManager.put("TreeUI", "org.LYG.GUI.platForm.UnicornTreeUI"); currentNodeName= new String(""); first= new LinkList(); nodeInfo= new NodeInfo(); nodeView= new NodeShow(this.tableData_old, this.text); nodeView.tree.setBackground(Color.white); nodeView.setBounds(10, 168, 137, 222); nodeProject= new NodeProject(); nodeProject.setBounds(10, 38, 137, 124); mainSplitPane = new UnicornJSplitPane(); mainSplitPane.setAutoscrolls(true); //mainSplitPane.setEnabled(false);// mainSplitPane.setBounds(10, 50, w-20, h-80); mainSplitPane.setVisible(true); getContentPane().add(mainSplitPane); leftSplitPane= new UnicornJSplitPane(); leftSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); mainSplitPane.setLeftComponent(leftSplitPane); leftSplitPane.setLeftComponent(nodeProject); leftSplitPane.setRightComponent(nodeView); rightSplitPane= new UnicornJSplitPane(); rightSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); mainSplitPane.setRightComponent(rightSplitPane); righttopSplitPane= new UnicornJSplitPane(); rightSplitPane.setLeftComponent(righttopSplitPane); rightBotJTextPane= new JTextPane(); rightBotJTextPane.setText("��ã���~"); nodeMenu= new PopupMenu(); canvas= new ThisCanvas(threadApplet, first, nodeView, nodeMenu, rightBotJTextPane); canvas.setPreferredSize(new Dimension(1500,1000)); canvas.setEnabled(true); righttopScrollPane= new JScrollPane(); righttopScrollPane.setViewportView(canvas); righttopSplitPane.setLeftComponent(righttopScrollPane); rightrightScrollPane= new JScrollPane(); righttopSplitPane.setRightComponent(nodeInfo); rightdownScrollPane= new JScrollPane(rightBotJTextPane); rightSplitPane.setRightComponent(rightdownScrollPane); popupMenu= new PopupMenu(); menuItem= new MenuItem(); menuItem.setLabel("add"); popupMenu.add(menuItem); configre= new MenuItem(); configre.setLabel("����"); run= new MenuItem(); run.setLabel("����"); show= new MenuItem(); show.setLabel("��ʾ"); dNode= new MenuItem(); dNode.setLabel("ɾ���ý�"); dLine= new MenuItem(); dLine.setLabel("ɾ������"); nodeMenu.add(configre); nodeMenu.add(run); nodeMenu.add(show); nodeMenu.add(dNode); nodeMenu.add(dLine); getContentPane().add(popupMenu); getContentPane().add(nodeMenu); engineMenu= new PopupMenu(); load= new MenuItem(); load.setLabel(StableData.CONFIG_LOAD); save= new MenuItem(); save.setLabel(StableData.CONFIG_UPDATE); saveAs= new MenuItem(); saveAs.setLabel(StableData.CONFIG_SAVE); delete= new MenuItem(); delete.setLabel(StableData.CONFIG_DELETE); boot= new MenuItem(); boot.setLabel(StableData.CONFIG_BOOT); bootETL= new MenuItem(); bootETL.setLabel(StableData.CONFIG_BOOT_ETL); engineMenu.add(load); engineMenu.add(save); engineMenu.add(saveAs); engineMenu.add(delete); engineMenu.add(boot); engineMenu.add(bootETL); getContentPane().add(engineMenu); getContentPane().setVisible(true); }
Example #28
Source File: InputMethodPopupMenu.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
void add(Object menuItem) { delegate.add((MenuItem)menuItem); }
Example #29
Source File: CMenu.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Override protected final void initialize(MenuItem target) { setLabel(target.getLabel()); setEnabled(target.isEnabled()); }
Example #30
Source File: CMenuItem.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private boolean isSeparator() { String label = ((MenuItem)getTarget()).getLabel(); return (label != null && label.equals("-")); }