List of utility methods to do Swing Menu
void | setMenuUp(boolean s, JComponent c) set Menu Up menuIsUp = s; if (s) popupMenu = c; else popupMenu = null; |
void | setViewportMenu(JComponent c) set Viewport Menu vpMenu = c; |
JPopupMenu | showContextMenu() show Context Menu JPopupMenu menu = new JPopupMenu(); Action cutAction = new StyledEditorKit.CutAction(); String cutActionCommand = (String) cutAction.getValue(Action.ACTION_COMMAND_KEY); JMenuItem cutItem = new JMenuItem(); cutItem.setActionCommand(cutActionCommand); cutItem.addActionListener(cutAction); cutItem.setText("Cut"); menu.add(cutItem); ... |
void | showRCMenu(JTextComponent text, MouseEvent e) show RC Menu int selStart = text.getSelectionStart(); int selEnd = text.getSelectionEnd(); JPopupMenu rightClickMenu = new JPopupMenu(); JMenuItem copyMenuItem = new JMenuItem(text.getActionMap().get(DefaultEditorKit.copyAction)); JMenuItem cutMenuItem = new JMenuItem(text.getActionMap().get(DefaultEditorKit.cutAction)); JMenuItem pasteMenuItem = new JMenuItem(text.getActionMap().get(DefaultEditorKit.pasteAction)); JMenuItem selectAllMenuItem = new JMenuItem(text.getActionMap().get(DefaultEditorKit.selectAllAction)); copyMenuItem.setText("Copy"); ... |
JMenu | toMenu(List Make a JMenu from an Action List JMenu menu = new JMenu(); for (Action a : actions) menu.add(a); return menu; |