Java JFrame Parent enableAllComponents(final boolean enable, final Frame parent)

Here you can find the source of enableAllComponents(final boolean enable, final Frame 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 Frame 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  w w. j  av a  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. buildParentFrame(Object inp)
  2. centreOverFrame(JInternalFrame win, JInternalFrame parent)
  3. closeFrameWhenEscapePressed(final JRootPane panel, final ActionListener actListener)
  4. createExceptionDialog(Frame parent, String title, Throwable error)
  5. createProgressDialog(Frame parentFrame, String title, JProgressBar progressBar)
  6. enableAllComponentsExcept(final boolean enable, final Frame parent, final Component... components)
  7. ensureVisibilityAtParent(final JInternalFrame frame)
  8. execLoop(JComponent editor, Frame parent, boolean modal, int w, int h)
  9. fileOpen(Frame parent, String typename, String ext)