@Override public String test(Window parent, Component component, int x, int y, String value) { ContextMenu m = new TestContextMenu(value); m.show(component, x, y); return null; } };
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("errors")) { GuiUtil.showNonModalMessage(getInvoker(), "Errors", errorsInfo, JOptionPane.WARNING_MESSAGE, true); } if (e instanceof CommandActionEvent) { CustomCommand command = ((CommandActionEvent)e).getCommand(); CommandSettings.showCommandInfoPopup(getInvoker(), command); } }
public TestContextMenu(String value) { final String readme = "Readme"; addItem("", "Test Context Menu", readme); addItem("", "a) Only shows custom menu items (not the pre-defined ones)", readme); addItem("", "b) Clicking on an item shows info about the associated command", readme); addItem("", "c) The associated command doesn't get executed", readme); addItem("", "(I hope you enjoy my abusing of a popup menu as an info list.)", readme); int errorCount = 0; List<CommandMenuItem> items = CommandMenuItems.parse(value); addItem("errors", errorCount+" Errors"); addSeparator(); for (CommandMenuItem item : items) { JMenuItem mItem = addCommandItem(item);