Here you can find the source of removeAllSeparators(JMenu menu)
Parameter | Description |
---|---|
menu | the menu whose separators will be removed |
public static void removeAllSeparators(JMenu menu)
//package com.java2s; /*/* w ww . java 2s .c o m*/ * Zed Attack Proxy (ZAP) and its related class files. * * ZAP is an HTTP/HTTPS proxy for assessing web application security. * * Copyright 2014 The ZAP Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.awt.Component; import javax.swing.JMenu; import javax.swing.JPopupMenu; public class Main { /** * Removes all separators from the given pop up menu. * * @param popupMenu the pop up menu whose separators will be removed * @see javax.swing.JPopupMenu.Separator */ public static void removeAllSeparators(JPopupMenu popupMenu) { for (int i = 0; i < popupMenu.getComponentCount(); i++) { if (isPopupMenuSeparator(popupMenu.getComponent(i))) { popupMenu.remove(i); i--; } } } /** * Convenience method that calls the method {@code removeAllSeparators(JPopupMenu)} with the {@code JPopupMenu} of the given * {@code menu} as parameter. * * @param menu the menu whose separators will be removed * @see #removeAllSeparators(JPopupMenu) * @see JMenu#getPopupMenu() * @see javax.swing.JPopupMenu.Separator */ public static void removeAllSeparators(JMenu menu) { removeAllSeparators(menu.getPopupMenu()); } /** * Tells whether or not the given {@code component} is a {@code JPopupMenu.Separator}. * * @param component the component that will be checked. * @return {@code true} if the given component is a {@code JPopupMenu.Separator}, {@code false} otherwise. * @see javax.swing.JPopupMenu.Separator * @see #isExtensionPopupMenu(Component) * @see #isExtensionPopupMenuItem(Component) */ public static boolean isPopupMenuSeparator(Component component) { return (component instanceof JPopupMenu.Separator); } }