/** * Provide the standard Groovy <code>size()</code> method for <code>JMenu</code>. * * @param self a JMenu * @return the menu component count of the menu * @since 1.6.4 */ public static int size(JMenu self) { return self.getMenuComponentCount(); }
@Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { Component componentSource = (Component) e.getSource(); JPopupMenu menu = new JPopupMenu(); for (int position = 0 ; position < MediatorGui.menubar().getMenuView().getMenuComponentCount() ; position++) { // Fix #35348: SerializationException on clone() try { JMenuItem itemMenu = (JMenuItem) SerializationUtils.clone(MediatorGui.menubar().getMenuView().getMenuComponent(position)); menu.add(itemMenu); final int positionFinal = position; itemMenu.addActionListener(actionEvent -> MediatorGui.tabManagers().setSelectedIndex(positionFinal)); } catch (SerializationException ex) { LOGGER.error(ex, ex); } } menu.show(componentSource, e.getX(), e.getY()); menu.setLocation( ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? e.getXOnScreen() - menu.getWidth() : e.getXOnScreen(), e.getYOnScreen() ); } }
/** * Provide the standard Groovy <code>size()</code> method for <code>JMenu</code>. * * @param self a JMenu * @return the menu component count of the menu * @since 1.6.4 */ public static int size(JMenu self) { return self.getMenuComponentCount(); }
/** * Provide the standard Groovy <code>size()</code> method for <code>JMenu</code>. * * @param self a JMenu * @return the menu component count of the menu * @since 1.6.4 */ public static int size(JMenu self) { return self.getMenuComponentCount(); }
/** * Provide the standard Groovy <code>size()</code> method for <code>JMenu</code>. * * @param self a JMenu * @return the menu component count of the menu * @since 1.6.4 */ public static int size(JMenu self) { return self.getMenuComponentCount(); }
private void setReticleOptionsMenu(JMenu menu) { if (reticleOptionsMenu != null) { reticleMenu.remove(reticleMenu.getMenuComponentCount() - 1); reticleMenu.remove(reticleMenu.getMenuComponentCount() - 1); } if (menu != null) { reticleMenu.addSeparator(); reticleMenu.add(menu); } reticleOptionsMenu = menu; }
@Override @ScriptFunction(jsDoc = MENU_COUNT_JSDOC) public int getCount() { return super.getMenuComponentCount(); }
public WindowMenuItem(EditWindow window, JMenu parentMenu) { super(); this.window = window; this.parentMenu = parentMenu; type = REGULAR_WINDOW; parentMenu.add(this, parentMenu.getMenuComponentCount() - SUBSEQUENT_WINDOW_MENU_ITEMS); addActionListener(this); }
private static <T extends Component> T findMenuComponent(JMenu menu, String menuComponentName, Class<T> componentClass) { for (int i = 0; i < menu.getMenuComponentCount(); i++) { Component component = menu.getMenuComponent(i); if (menuComponentName.equals(component.getName()) && componentClass.isInstance(component)) return componentClass.cast(component); } return null; }
@Override public void addSeparator() { int count = target.getMenuComponentCount(); boolean canAddSeparator = count != 0 && target.getMenuComponent(count-1).getClass() != JPopupMenu.Separator.class; if ( canAddSeparator ) target.addSeparator(); }
@Override public void addSeparator() { int count = target.getMenuComponentCount(); boolean canAddSeparator = count != 0 && target.getMenuComponent(count-1).getClass() != JPopupMenu.Separator.class; if ( canAddSeparator ) target.addSeparator(); }
public void update(JMenu menu) { Vector macroVector = Macros.getMacroHierarchy(); int count = menu.getMenuComponentCount(); createMacrosMenu(menu,macroVector,0); if(count == menu.getMenuComponentCount()) { JMenuItem mi = new JMenuItem(jEdit.getProperty( "no-macros.label")); mi.setEnabled(false); menu.add(mi); } } //}}}
/** * Remove any potential orphan separator at the end of the menu. * * @param menu the menu to purge */ public static void trimSeparator (JMenu menu) { int count = menu.getMenuComponentCount(); if ((count > 0) && menu.getMenuComponent(count - 1) instanceof JSeparator) { menu.remove(count - 1); } } }
protected void enableUserDefined() { DockedTypeDescriptor descriptor = (DockedTypeDescriptor) toolWindow.getTypeDescriptor(ToolWindowType.DOCKED); if (old != null) { popupMenu.remove(old); } JMenu menu = descriptor.getToolsMenu(); if (menu.getMenuComponentCount() > 0) { popupMenu.add(menu, 4); old = menu; } }
JMenuBar menubar1 = getJMenuBar(); for (int i = 0; i < menubar1.getMenuCount(); i++) { JMenu menu1 = menubar1.getMenu(i); System.out.println("Menu:" + menu1.getText()); for (int j = 0; j < menu1.getMenuComponentCount(); j++) { java.awt.Component comp = menu1.getMenuComponent(j); if (comp instanceof JMenuItem) { JMenuItem menuItem1 = (JMenuItem) comp; System.out.println("MenuItem:" + menuItem1.getText()); } } }
private static void updateMenu(final JMenu _m,final String actionCommand){ for (int i = _m.getMenuComponentCount() - 1; i >= 0; i--) { if (_m.getMenuComponent(i) instanceof JMenuItem) { final JMenuItem it = (JMenuItem) _m.getMenuComponent(i); it.setSelected(it.getActionCommand().equals(actionCommand)); } } }
JMenuBar menubar1 = getJMenuBar(); for (int i = 0; i < menubar1.getMenuCount(); i++) { JMenu menu1 = menubar1.getMenu(i); System.out.println("Menu:" + menu1.getText()); for (int j = 0; j < menu1.getMenuComponentCount(); j++) { java.awt.Component comp = menu1.getMenuComponent(j); if (comp instanceof JMenuItem) { JMenuItem menuItem1 = (JMenuItem) comp; System.out.println("MenuItem:" + menuItem1.getText()); } } }
public void contentsChanged(ListDataEvent e) { for (int i = e.getIndex0(); i <= e.getIndex1(); i++) { if (i >= 0 && i < menu.getMenuComponentCount()) { BaseRoute route = formatAndRoutesModel.getRoute(i); JMenuItem menuItem = (JMenuItem) menu.getMenuComponent(i); menuItem.setText(shortenRouteName(route)); } } } });
/** * Print menu items - for debugging */ private void printMenu(JMenu jm) { int count = jm.getMenuComponentCount(); for (int i = 0; i < count; i++) { if (jm.getItem(i).getClass().getName().equals("javax.swing.JMenuItem")) { logger.debug(jm.getItem(i).getText()); continue; } else { logger.debug(jm.getItem(i).getText() + "--"); printMenu((JMenu) jm.getItem(i)); } } }
public void intervalRemoved(ListDataEvent e) { for (int i = e.getIndex1(); i >= e.getIndex0(); i--) { JMenuItem menuItem = i < menu.getMenuComponentCount() ? (JMenuItem) menu.getMenuComponent(i) : null; if (menuItem != null) { MergePositionListAction action = (MergePositionListAction) menuItem.getAction(); action.dispose(); menuItem.setAction(null); } if (menu.getItemCount() > i) menu.remove(i); } menu.setEnabled(formatAndRoutesModel.getSize() > 1); }