use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.
the class Test8013370 method run.
@Override
public void run() {
if (this.frame == null) {
JMenuBar menu = new JMenuBar() {
@Override
protected boolean processKeyBinding(KeyStroke stroke, KeyEvent event, int condition, boolean pressed) {
if (stroke == null) {
Test8013370.this.error = true;
return false;
}
return super.processKeyBinding(stroke, event, condition, pressed);
}
};
menu.add(new JMenuItem("Menu"));
InputMap map = menu.getInputMap(WHEN_IN_FOCUSED_WINDOW);
// from a array to a hashtable when more than 8 values are added.
for (int i = 0; i < 9; i++) {
String name = " Action #" + i;
map.put(KeyStroke.getKeyStroke(KeyEvent.VK_A + i, CTRL_DOWN_MASK), name);
menu.getActionMap().put(name, new AbstractAction(name) {
@Override
public void actionPerformed(ActionEvent event) {
showMessageDialog(null, getValue(NAME));
}
});
}
this.frame = new JFrame("8013370");
this.frame.setJMenuBar(menu);
this.frame.setVisible(true);
} else {
this.frame.dispose();
}
}
use of javax.swing.JMenuBar in project processdash by dtuma.
the class AbstractCustomProcessEditor method buildMenuBar.
private JMenuBar buildMenuBar() {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menuBar.add(menu);
menu.add(newMenuItem = new JMenuItem("New"));
newMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
stopEditing(frame);
newProcess();
}
});
menu.add(openMenuItem = new JMenuItem("Open..."));
openMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
stopEditing(frame);
openProcess();
}
});
menu.add(saveMenuItem = new JMenuItem("Save..."));
saveMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
stopEditing(frame);
save();
}
});
menu.add(closeMenuItem = new JMenuItem("Close"));
closeMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
stopEditing(frame);
confirmClose(true);
}
});
return menuBar;
}
use of javax.swing.JMenuBar in project processdash by dtuma.
the class ShowGlobalGroupFilterSelector method getMainGroupFilterMenu.
private GroupFilterMenu getMainGroupFilterMenu() {
ProcessDashboard dash = (ProcessDashboard) getDashboardContext();
JMenuBar menuBar = dash.getConfigurationMenus();
for (int i = menuBar.getMenuCount(); i-- > 0; ) {
Object item = menuBar.getMenu(i);
if (item instanceof GroupFilterMenu)
return (GroupFilterMenu) item;
}
return null;
}
use of javax.swing.JMenuBar in project processdash by dtuma.
the class SimulationHarness method selectNode.
public void selectNode(String node) {
String[] path = node.split("/");
JMenuBar menuBar = getHierarchyMenuBar();
for (int i = 0; i < path.length; i++) {
JMenu menu = menuBar.getMenu(i);
int j = 0;
for (; j < menu.getMenuComponentCount(); j++) {
JMenuItem menuItem = menu.getItem(i);
if (path[i].equals(menuItem.getText())) {
menuItem.doClick();
uiDelay();
break;
}
}
if (j == menu.getMenuComponentCount())
throw new IllegalStateException("Could not select node " + node);
}
}
use of javax.swing.JMenuBar in project cayenne by apache.
the class OSXPlatformInitializer method setupMenus.
public void setupMenus(JFrame frame) {
// set additional look and feel for the window
frame.getRootPane().putClientProperty("apple.awt.brushMetalLook", Boolean.TRUE);
Set<Action> removeActions = new HashSet<>();
removeActions.add(actionManager.getAction(ExitAction.class));
removeActions.add(actionManager.getAction(AboutAction.class));
removeActions.add(actionManager.getAction(ConfigurePreferencesAction.class));
JMenuBar menuBar = frame.getJMenuBar();
for (Component menu : menuBar.getComponents()) {
if (menu instanceof JMenu) {
JMenu jMenu = (JMenu) menu;
Component[] menuItems = jMenu.getPopupMenu().getComponents();
for (int i = 0; i < menuItems.length; i++) {
if (menuItems[i] instanceof JMenuItem) {
JMenuItem jMenuItem = (JMenuItem) menuItems[i];
if (removeActions.contains(jMenuItem.getAction())) {
jMenu.remove(jMenuItem);
// the current (as of 08.2010) menu layout
if (i > 0 && i == menuItems.length - 1 && menuItems[i - 1] instanceof JPopupMenu.Separator) {
jMenu.remove(i - 1);
}
}
}
}
}
}
}
Aggregations