Here you can find the source of enableAllComponentsExcept(final boolean enable, final JDialog parent, final Component... components)
Parameter | Description |
---|---|
enable | a parameter |
parent | a parameter |
components | a parameter |
public static void enableAllComponentsExcept(final boolean enable, final JDialog parent, final Component... components)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import java.awt.Frame; import java.util.Arrays; import javax.swing.JDialog; public class Main { /**/*from ww w . j ava 2 s.c om*/ * Enables/Disables all the components of a Frame except the specified components based on the * input. * * @param enable * @param parent * @param components */ public static void enableAllComponentsExcept(final boolean enable, final Frame parent, final Component... components) { if (null != parent) { Component[] allComponents = parent.getComponents(); if (null == allComponents) { return; } if (allComponents.length <= 0) { return; } for (Component component : allComponents) { if (null != component && components != null) { if (contains(component, components)) { continue; } component.setEnabled(enable); } } } } /** * Enables/Disables all the components of a Frame except the specified components based on the * input. * * @param enable * @param parent * @param components */ public static void enableAllComponentsExcept(final boolean enable, final JDialog parent, final Component... components) { if (null != parent) { Component[] allComponents = parent.getRootPane().getComponents(); if (null == allComponents) { return; } if (allComponents.length <= 0) { return; } for (Component component : allComponents) { if (null != component && components != null) { if (contains(component, components)) { continue; } component.setEnabled(enable); } } } } /** * * @param item * @param items * @return */ public static <T> boolean contains(T item, T... items) { if (null == item || null == items) { return false; } if (items.length <= 0) { return false; } return Arrays.asList(items).contains(item); } }