List of utility methods to do Swing Menu Item
int | getTextOffset(JComponent menuItem, Component menuItemParent) Returns the text offset of the specified menu item. if (!(menuItemParent instanceof JPopupMenu)) { return 0; Object itemProp = menuItem.getClientProperty(GUTTER_X); if (itemProp instanceof Integer) { return (Integer) itemProp; JPopupMenu popupMenu = (JPopupMenu) menuItemParent; ... |
JCheckBoxMenuItem | getTexturesMenuItem() get Textures Menu Item texturesMenuItem.setToolTipText("Turn textures on/off"); return texturesMenuItem; |
JPanel | getTopicsMenuItem(ActionListener l) get Topics Menu Item JPanel panel = new JPanel(); lexpand = new JButton(maxicon); lexpand.setActionCommand("left-expand"); lexpand.setToolTipText("Expand window"); lexpand.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lexpand.setPreferredSize(new Dimension(16, 16)); lexpand.addActionListener(l); panel.add(lexpand); ... |
boolean | isSynthUI(final MenuItemUI ui) is Synth UI Class<?> aClass = ui.getClass(); while (aClass != null && aClass.getSimpleName().contains("Synth")) { final Class<?>[] interfaces = aClass.getInterfaces(); for (int i = 0, length = interfaces.length; i < length; i++) { final Class<?> anInterface = interfaces[i]; if (V6_SYNTH_UI_CLASS.equals(anInterface.getName()) || V7_SYNTH_UI_CLASS.equals(anInterface.getName())) { return true; ... |
JMenuItem | loadMenuItem(String action) This method creates a new JMenuItem. return null;
|
JCheckBoxMenuItem | makeCheckboxMenuItem(String label, final Object object, final String property, final Object arg) Make a checkbox menu item. boolean value = true; try { String methodName = "get" + property.substring(0, 1).toUpperCase() + property.substring(1); Method theMethod = findMethod(object.getClass(), methodName, ((arg == null) ? new Class[] {} : new Class[] { arg.getClass() })); if (theMethod != null) { Boolean v = (Boolean) theMethod.invoke(object, ((arg == null) ? new Object[] {} : new Object[] { arg })); ... |
JMenu | makeMenu(String name, List menuItems) Create a JMenu and add the menus contained with the menus list If no menus then return null. return makeMenu(new JMenu(name), menuItems); |
JMenuItem | makeMenuItem(Icon icon, Icon rollover, String menu_cmd, boolean is_toggle, int mnemonic, int accel) _more_ JMenuItem mi; if (is_toggle) { mi = new JCheckBoxMenuItem(menu_cmd); } else { mi = new JMenuItem(menu_cmd); if (icon != null) { mi.setIcon(icon); ... |
JMenuItem | makeMenuItem(Icon icon, Icon rollover, String menu_cmd, boolean is_toggle, int mnemonic, int accel) make Menu Item JMenuItem mi; if (is_toggle) mi = new JCheckBoxMenuItem(menu_cmd); else mi = new JMenuItem(menu_cmd); if (icon != null) mi.setIcon(icon); if (rollover != null) { ... |
JMenuItem | makeMenuItem(String label, final Object object, final String methodName) Make a jmenuItem. return makeMenuItem(label, object, methodName, null, false);
|