/** * Adds a single item to this roles popup menu. * * <p>This method is used by ClassTarget to add some standard menus as well as by the roles to add * menus. It should be overridden with caution. * * @param menu the popup menu the item is to be added to * @param action the action to be registered with this menu item * @param itemString the String to be displayed on menu item * @param enabled boolean value representing whether item should be enabled */ public void addMenuItem(JPopupMenu menu, Action action, boolean enabled) { JMenuItem item; item = new JMenuItem(); item.setAction(action); item.setFont(PrefMgr.getPopupMenuFont()); item.setForeground(envOpColour); item.setEnabled(enabled); menu.add(item); }
/** * Create the menu items for the given members (constructors or methods). * * @return true if any items were created */ public static boolean createMenuItems( JPopupMenu menu, CallableView[] members, ViewFilter filter, int first, int last, String prefix, InvokeListener il) { // Debug.message("Inside ClassTarget.createMenuItems\n first = " + first // + " last = " + last); boolean hasEntries = false; JMenuItem item; for (int i = first; i < last; i++) { try { CallableView m = members[last - i - 1]; if (!filter.accept(m)) continue; // Debug.message("createSubMenu - creating MenuItem"); Action callAction = null; if (m instanceof MethodView) callAction = new InvokeAction((MethodView) m, il, prefix + m.getLongDesc()); else if (m instanceof ConstructorView) callAction = new ConstructAction((ConstructorView) m, il, prefix + m.getLongDesc()); if (callAction != null) { item = menu.add(callAction); item.setFont(PrefMgr.getPopupMenuFont()); hasEntries = true; } } catch (Exception e) { Debug.reportError("Exception accessing methods: " + e); e.printStackTrace(); } } return hasEntries; }
private void addMenuItem(JPopupMenu menu, Action action) { JMenuItem item = menu.add(action); item.setFont(PrefMgr.getPopupMenuFont()); item.setForeground(envOpColour); }