Java JDialog enableAllComponents(final boolean enable, final JDialog parent)

Here you can find the source of enableAllComponents(final boolean enable, final JDialog parent)

Description

Enables/Disables all the components of a Frame based on the input.

License

Apache License

Parameter

Parameter Description
enable a parameter
parent a parameter

Declaration

public static void enableAllComponents(final boolean enable, final JDialog parent) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Component;

import java.awt.Frame;

import javax.swing.JDialog;

public class Main {
    /**//from  w ww .  j  a va  2 s .c o  m
     * Enables/Disables all the components of a Frame based on the input.
     *
     * @param enable
     * @param parent
     */
    public static void enableAllComponents(final boolean enable, final Frame parent) {
        if (null != parent) {
            Component[] components = parent.getComponents();
            if (null == components) {
                return;
            }
            if (components.length <= 0) {
                return;
            }
            for (Component component : components) {
                if (null != component) {
                    component.setEnabled(enable);
                }
            }
        }
    }

    /**
     * Enables/Disables all the components of a Frame based on the input.
     *
     * @param enable
     * @param parent
     */
    public static void enableAllComponents(final boolean enable, final JDialog parent) {
        if (null != parent) {
            Component[] components = parent.getRootPane().getComponents();
            if (null == components) {
                return;
            }
            if (components.length <= 0) {
                return;
            }
            for (Component component : components) {
                if (null != component) {
                    component.setEnabled(enable);
                }
            }
        }
    }
}

Related

  1. commonFileDialog(JDialog parent, boolean save)
  2. configureCancelForDialog(final JDialog dialog, JButton cancelButton)
  3. decorate(JDialog dialog, int type)
  4. displayInDialog(JComponent comp, JDialog result)
  5. disposeOnClose(javax.swing.JDialog d)
  6. enableAllComponentsExcept(final boolean enable, final JDialog parent, final Component... components)
  7. endTask(javax.swing.JDialog jp)
  8. findJDialog(Component c)
  9. fit(JDialog d)