Example usage for java.awt Component setEnabled

List of usage examples for java.awt Component setEnabled

Introduction

In this page you can find the example usage for java.awt Component setEnabled.

Prototype

public void setEnabled(boolean b) 

Source Link

Document

Enables or disables this component, depending on the value of the parameter b .

Usage

From source file:Main.java

/**
 * Disables component and all of its children recursively.
 *
 * @param component       component to disable
 * @param startFromChilds whether should disable only component childs or not
 * @param excludePanels   whether should exclude panels from disabling or not
 * @param excluded        components to exclude from disabling
 * @param disabled        list of actually disabled components
 *//*  w w w. ja  v  a 2  s  .co  m*/
private static void disableRecursively(final Component component, final boolean startFromChilds,
        final boolean excludePanels, final List<Component> excluded, final List<Component> disabled) {
    final boolean b = !startFromChilds && !excluded.contains(component)
            && !(component instanceof JPanel && excludePanels);
    if (b && component.isEnabled()) {
        component.setEnabled(false);
        disabled.add(component);
    }
    if (component instanceof Container) {
        if (b && isHandlesEnableState(component)) {
            return;
        }
        final Container container = (Container) component;
        for (final Component child : container.getComponents()) {
            disableRecursively(child, false, excludePanels, excluded, disabled);
        }
    }
}

From source file:Main.java

/**
 * Enable container.//from w ww .  j  ava 2  s  .  c om
 *
 * @param cont
 *            the cont
 * @param enable
 *            the enable
 */
public static void enableContainer(final Container cont, final boolean enable) {
    final int count = cont.getComponentCount();
    Component comp;
    for (int i = 0; i < count; i++) {
        comp = cont.getComponent(i);
        if (comp instanceof JPanel || comp instanceof Box) {
            enableContainer((Container) comp, enable);
        } else {
            if (comp instanceof JTextField) {
                ((JTextField) comp).setEnabled(enable);
            } else if (!(comp instanceof JLabel)) {
                comp.setEnabled(enable);
            }
        }
    }
}

From source file:core.PlanC.java

/**
 * set the enable/disable status for all JMenuItem inside of MenuBar
 * /*www .  ja  va 2 s .  c  om*/
 * @param e - enable status
 */
public static void setEnableJmenubar(boolean e) {
    Component[] cmps = menuBar.getComponents();
    for (Component cmp : cmps) {
        if (cmp instanceof JMenuItem) {
            cmp.setEnabled(e);
        }
    }
}

From source file:Main.java

private void setComponentEnabled(boolean enabled, Component component) {
    component.setEnabled(enabled);
    if (component instanceof Container) {
        Component[] components = ((Container) component).getComponents();
        if (components != null && components.length > 0) {
            for (Component heldComponent : components) {
                setComponentEnabled(enabled, heldComponent);
            }/*from   w ww.j  av  a 2  s. c  o m*/
        }
    }
}

From source file:com.microsoft.azuretools.ijidea.ui.AppServiceChangeSettingsDialog.java

protected AppServiceChangeSettingsDialog(Project project, WebAppDetails wad) {
    super(project);

    setTitle("Change App Service Settings");

    setOKButtonText("Change");

    webApp = wad.webApp;/*www. j  a  v a  2  s .c o  m*/
    textFieldWebappName.setText(wad.webApp.name());
    textFieldWebappName.setEnabled(false);

    DefaultComboBoxModel<WebContainer> wcModel = (DefaultComboBoxModel<WebContainer>) comboBoxWebContainer
            .getModel();
    if (wad.webApp.javaVersion() != JavaVersion.OFF) {
        wcModel.setSelectedItem(
                new WebContainer(wad.webApp.javaContainer() + " " + wad.webApp.javaContainerVersion()));
    }

    comboBoxSubscription.setEnabled(false);

    DefaultComboBoxModel<ResourceGroupAdapter> rgModel = (DefaultComboBoxModel<ResourceGroupAdapter>) comboBoxResourceGroup
            .getModel();
    rgModel.setSelectedItem(new ResourceGroupAdapter(wad.resourceGroup));
    for (Component c : panelResourceGroupUseExisting.getComponents()) {
        c.setEnabled(false);
    }

    for (Component c : panelResourceGroup.getComponents()) {
        c.setEnabled(false);
    }

    DefaultComboBoxModel<AppServicePlanAdapter> aspModel = (DefaultComboBoxModel<AppServicePlanAdapter>) comboBoxAppServicePlan
            .getModel();
    aspModel.setSelectedItem(new AppServicePlanAdapter(wad.appServicePlan));
    //comboBoxAppServicePlan.setEnabled(false);
    for (Component c : panelAppServiceUseExisting.getComponents()) {
        c.setEnabled(false);
    }

    for (Component c : panelAppServicePlan.getComponents()) {
        c.setEnabled(false);
    }
}

From source file:eu.novait.imagerenamer.gui.MainWindow.java

public void setCurrentState(int state) {
    this.currentState = state;
    switch (this.currentState) {
    case STATE_LOADING:
    case STATE_SAVING:
        for (Component c : this.jToolBar1.getComponents()) {
            c.setEnabled(false);
        }//  w  w w .j a  v a  2  s.  com
        this.jMenu1.setEnabled(false);
        this.jTable1.setEnabled(false);
        this.statusPanel.setVisible(true);
        break;
    case STATE_WAITING:
    default:
        this.jMenu1.setEnabled(true);
        for (Component c : this.jToolBar1.getComponents()) {
            c.setEnabled(true);
        }
        this.jTable1.setEnabled(true);
        this.statusPanel.setVisible(false);
        this.loaderBar.setValue(0);
        this.loaderBar.setMaximum(1);
    }
}

From source file:de.codesourcery.eve.skills.ui.components.AbstractComponent.java

protected void linkComponentEnabledStates(final JToggleButton parent, final Component... children) {

    final boolean selected = parent.isSelected();

    for (Component child : children) {
        child.setEnabled(selected);
    }//  ww  w  .  j a  v  a 2s. c  o m

    parent.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {

            final boolean selected = e.getStateChange() == ItemEvent.SELECTED;

            for (Component child : children) {
                child.setEnabled(selected);
            }
        }
    });

}

From source file:de.mprengemann.intellij.plugin.androidicons.dialogs.AndroidBatchScaleImporter.java

private void createUIComponents() {
    table = new JBTable() {
        @NotNull//from  w  w  w .java2 s.c  om
        @Override
        public Component prepareRenderer(@NotNull TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            c.setEnabled(isCellEditable(row, column));
            return c;
        }
    };
    addButton = new JButton(getIcon("ic_action_add"));
    editButton = new JButton(getIcon("ic_action_edit"));
    deleteButton = new JButton(getIcon("ic_action_trash"));
}

From source file:at.tuwien.ifs.feature.evaluation.SimilarityRetrievalGUI.java

private void initPanelRetrieval() {
    panelRetrieval = new JPanel(new GridBagLayout()) {
        private static final long serialVersionUID = 1L;

        @Override/*w  w w  . ja v  a2 s  .c o  m*/
        public void setEnabled(boolean enabled) {
            // also enable all subcomponents
            super.setEnabled(enabled);
            for (Component c : panelRetrieval.getComponents()) {
                c.setEnabled(enabled);
            }
        }

    };
}

From source file:com.mirth.connect.client.ui.panels.export.MessageExportPanel.java

private void archiveChanged() {
    if (archiveYes.isSelected()) {
        for (Component component : archiveComponents) {
            component.setEnabled(true);
        }//from   w w w.  j a v a 2 s.c  o  m
    } else {
        resetInvalidProperties();

        for (Component component : archiveComponents) {
            component.setEnabled(false);
        }
    }
}