use of javax.swing.JMenuItem in project adempiere by adempiere.
the class POSActionMenu method addMenuItem.
private void addMenuItem(String optionName) {
JMenuItem menuItem = new JMenuItem(optionName);
popupMenu.add(menuItem).addActionListener(this);
}
use of javax.swing.JMenuItem in project adempiere by adempiere.
the class CompiereToolTipUI method getAcceleratorString.
/**
* Get Accelerator String
* @return string
*/
public String getAcceleratorString() {
String str = super.getAcceleratorString();
if (tip == null || isAcceleratorHidden())
return str;
JComponent comp = tip.getComponent();
if (comp == null || comp instanceof JTabbedPane || comp instanceof JMenuItem)
return str;
KeyStroke[] keys = comp.getRegisteredKeyStrokes();
StringBuffer controlKeyStr = new StringBuffer();
for (int i = 0; i < keys.length; i++) {
int mod = keys[i].getModifiers();
int condition = comp.getConditionForKeyStroke(keys[i]);
if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
String prefix = KeyEvent.getKeyModifiersText(mod);
if (prefix.length() > 1) {
if (controlKeyStr.length() > 0)
controlKeyStr.append(" ");
controlKeyStr.append(prefix).append("-").append(KeyEvent.getKeyText(keys[i].getKeyCode()));
// just first
break;
}
}
}
return controlKeyStr.toString();
}
use of javax.swing.JMenuItem in project jmeter by apache.
the class MenuFactory method makeMenuItem.
public static JMenuItem makeMenuItem(String label, String name, String actionCommand, KeyStroke accel) {
JMenuItem item = makeMenuItem(label, name, actionCommand);
item.setAccelerator(accel);
return item;
}
use of javax.swing.JMenuItem in project joda-time by JodaOrg.
the class DateTimeBrowser method addMenus.
/*
* addMenus
*/
private void addMenus(JMenuBar menuBar) {
//
// Create all the menus.
//
JMenu fileMenu = new JMenu("File");
JMenu viewMenu = new JMenu("View");
//
// Add them to the menubar in order.
//
menuBar.add(fileMenu);
menuBar.add(viewMenu);
//
// Create action objects and menu items.
//
Action open = new OpenAction();
JMenuItem jmiOpen = new JMenuItem(open);
Action exit = new ExitAction();
JMenuItem jmiExit = new JMenuItem(exit);
//
// Next Menu
//
Action getter = new GetterAction();
jmiGetter = new JMenuItem(getter);
getter.setEnabled(true);
//
Action hex = new HexAction();
jmiHex = new JMenuItem(hex);
hex.setEnabled(true);
//
Action date = new DateAction();
jmiDate = new JMenuItem(date);
date.setEnabled(true);
//
Action cal = new CalAction();
jmiCal = new JMenuItem(cal);
cal.setEnabled(true);
//
// Build the file menu.
//
fileMenu.add(jmiOpen);
fileMenu.addSeparator();
fileMenu.add(jmiExit);
//
// Build the view menu.
//
viewMenu.add(jmiGetter);
viewMenu.add(jmiHex);
viewMenu.add(jmiDate);
viewMenu.add(jmiCal);
//
// *temp Developer's code
//
// jmiGetter.setEnabled( false );
//
// JMenuItem getter2 = new JMenuItem( "getter2" );
// getter2.addActionListener( new myMouseListener() );
// viewMenu.add( getter2 );
}
use of javax.swing.JMenuItem in project jadx by skylot.
the class TabbedPane method createTabPopupMenu.
private JPopupMenu createTabPopupMenu(final ContentPanel contentPanel) {
JPopupMenu menu = new JPopupMenu();
JMenuItem closeTab = new JMenuItem(NLS.str("tabs.close"));
closeTab.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
closeCodePanel(contentPanel);
}
});
menu.add(closeTab);
if (openTabs.size() > 1) {
JMenuItem closeOther = new JMenuItem(NLS.str("tabs.closeOthers"));
closeOther.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
List<ContentPanel> contentPanels = new ArrayList<ContentPanel>(openTabs.values());
for (ContentPanel panel : contentPanels) {
if (panel != contentPanel) {
closeCodePanel(panel);
}
}
}
});
menu.add(closeOther);
JMenuItem closeAll = new JMenuItem(NLS.str("tabs.closeAll"));
closeAll.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
closeAllTabs();
}
});
menu.add(closeAll);
menu.addSeparator();
ContentPanel selectedContentPanel = getSelectedCodePanel();
for (final Map.Entry<JNode, ContentPanel> entry : openTabs.entrySet()) {
final ContentPanel cp = entry.getValue();
if (cp == selectedContentPanel) {
continue;
}
JNode node = entry.getKey();
final String clsName = node.makeLongString();
JMenuItem item = new JMenuItem(clsName);
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setSelectedComponent(cp);
}
});
item.setIcon(node.getIcon());
menu.add(item);
}
}
return menu;
}
Aggregations