Here you can find the source of isAtLeastOneChildComponentVisible(JMenu menu)
Parameter | Description |
---|---|
menu | the menu that will be checked |
public static boolean isAtLeastOneChildComponentVisible(JMenu menu)
//package com.java2s; /*/*from ww w . j a v a2 s . 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 java.awt.Container; import javax.swing.JMenu; public class Main { /** * Tells whether or not the given {@code component} has at least one child component visible. * * @param component the component that will be checked * @return {@code true} if at least one child component is visible, {@code false} otherwise. */ public static boolean isAtLeastOneChildComponentVisible(Container component) { for (Component comp : component.getComponents()) { if (comp.isVisible()) { return true; } } return false; } /** * Convenience method that calls the method {@code isAtLeastOneChildComponentVisible(Container)} with the {@code JPopupMenu} * of the given {@code menu} as parameter. * * @param menu the menu that will be checked * @return {@code true} if at least one child component is visible, {@code false} otherwise. * @see #isAtLeastOneChildComponentVisible(Container) * @see JMenu */ public static boolean isAtLeastOneChildComponentVisible(JMenu menu) { return isAtLeastOneChildComponentVisible(menu.getPopupMenu()); } }