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:com.diversityarrays.kdxplore.curate.SampleEntryPanel.java

/**
 * @param show/*from  ww  w. j a v  a 2 s.com*/
 */
private void updateStatsControls(boolean showStats) {

    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                updateStatsControls(showStats);
            }
        });
        return;
    }

    if (showStats) {
        repopulatingStatsControls = true;
        try {
            doRepopulateStatsControls();
        } finally {
            repopulatingStatsControls = false;
        }
        statisticsControls.setVisible(true);
    } else {
        statisticsControls.setVisible(false);

        for (JButton btn : statButtonByStatType.values()) {
            btn.setEnabled(false);
        }
        for (Component component : statComponentByStatType.values()) {
            component.setEnabled(false);
        }
    }
    this.repaint();
    this.updateUI();
}

From source file:com.diversityarrays.kdxplore.curate.SampleEntryPanel.java

private void doRepopulateStatsControls() {
    for (StatType statType : StatType.values()) {
        Object statValue = statType.getStatValue(kdsmartSampleStatistics);

        statButtonByStatType.get(statType).setEnabled(statValue != null);

        Component component = statComponentByStatType.get(statType);
        if (statType != StatType.MODE) {
            component.setEnabled(statValue != null);
            ((JButton) component).setText(statValue == null ? "" : statValue.toString()); //$NON-NLS-1$
        } else {//from   www  .  ja va  2s .  c om
            @SuppressWarnings("unchecked")
            JComboBox<String> comboBox = (JComboBox<String>) component;

            comboBox.removeAllItems();
            String[] modesArray = (String.valueOf(statValue)).split(",", -1); //$NON-NLS-1$
            List<String> modes = Arrays.asList(modesArray);
            if (modes.size() > 1) {
                comboBox.setEnabled(true);
                for (String s : modes) {
                    if (s.trim() != null) {
                        comboBox.addItem(s.trim());
                    }
                }
            } else {
                comboBox.setEnabled(true);
                comboBox.addItem(String.valueOf(statValue));
            }
        }
    }
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java

/**
 * Sets the data into the form for a given index.
 * @param index the index of the record to be set
 *//*  w  ww .  ja v a 2 s  . com*/
protected void setDataIntoForm(final int index) {
    if (index < 0) {
        ignoreChanges = true;
        for (InputPanel panel : uiComps) {
            panel.getLabel().setEnabled(false);
            Component comp = panel.getComp();
            comp.setEnabled(false);
            if (comp instanceof JTextComponent) {
                ((JTextComponent) comp).setText("");
            } else if (comp instanceof JCheckBox) {
                ((JCheckBox) comp).setSelected(false);
            }
        }
        ignoreChanges = false;

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                workbenchPane.getResultSetController().getNewRecBtn().requestFocus();
            }
        });

        return;

    } else if (index == 0 && workbench.getWorkbenchRowsAsList().size() == 1) {
        for (InputPanel panel : uiComps) {
            panel.getLabel().setEnabled(true);
            panel.getComp().setEnabled(true);
        }
    }

    ignoreChanges = true; // turn off change notification

    int modelIndex = workbenchPane.getSpreadSheet().convertRowIndexToModel(index);
    WorkbenchRow wbRow = workbench.getWorkbenchRowsAsList().get(modelIndex);
    for (InputPanel p : uiComps) {
        int col = p.getWbtmi().getViewOrder();

        if (p.getComp() instanceof GetSetValueIFace) {
            ((GetSetValueIFace) p.getComp()).setValue(wbRow.getData(col), wbRow.getData(col));

        } else if (p.getComp() instanceof JComboBox) {
            ((JComboBox) p.getComp()).setSelectedItem(wbRow.getData(col));
        } else if (p.getComp() instanceof JScrollPane) {
            JScrollPane sc = (JScrollPane) p.getComp();
            Component comp = sc.getViewport().getView();
            if (comp instanceof JTextArea) {
                ((JTextArea) comp).setText(wbRow.getData(col));
            }
        } else {
            ((JTextComponent) p.getComp()).setText(wbRow.getData(col));
        }
    }
    ignoreChanges = false;
}

From source file:com.vectionvr.jort.gui.MainFrame.java

private void setChildsEnabled(final Component component, final boolean enabled) {
    if (component instanceof JPanel) {
        for (final Component subComponent : ((JPanel) component).getComponents()) {
            setChildsEnabled(subComponent, enabled);
        }//  w  w w. ja va  2s  . c o  m
    } else if (!(component instanceof JLabel) && !(component instanceof JButton)) {
        component.setEnabled(enabled);
    }
}

From source file:edu.ku.brc.af.ui.forms.validation.FormValidator.java

/**
 * Helper methods for turning on the "default" OK button after a validation was completed.
 * @param itsOKToEnable indicates whether it is OK to enable the "OK" button
 *///from ww  w . j ava 2  s .co  m
protected void enableUIItems(final boolean itsOKToEnable, final EnableType type) {
    //log.debug(name+" hasChanged ["+hasChanged+"]     itsOKToEnable ["+itsOKToEnable+ "]    enableItems: [" + type+"]");

    for (Component comp : enableHash.get(type)) {
        comp.setEnabled(itsOKToEnable);
    }
    updateValidationBtnUIState();

    //log.debug("UIValidator.isIgnoreAllValidation() "+UIValidator.isIgnoreAllValidation());
    //log.debug(name+" type "+type+"  itsOKToEnable "+itsOKToEnable);
    if ((type == saveEnableType || type == EnableType.ValidAndChangedItems) && saveComp != null
            && !UIValidator.isIgnoreAllValidation()) {
        if (itsOKToEnable) {
            saveComp.setEnabled(isFormValid(true));
        } else {
            saveComp.setEnabled(false);
        }
    }
}

From source file:SuitaDetails.java

public void setEnabled(boolean enabled) {
    super.setEnabled(enabled);
    for (Component component : getComponents())
        component.setEnabled(enabled);
}

From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java

/**
 * Recursively disables or enables all swing and awt components in this
 * dialog, starting with but not including the container
 * <code>startContainer</code>.
 *
 * @param startContainer/*from w  w  w  . j av  a  2s .c  o m*/
 *            The GUI Element to start with.
 * @param enable
 *            <code>true</code>, if all elements will get enabled,
 *            <code>false</code> if all elements will get disabled.
 */
private void disOrEnableAllElements(Container startContainer, boolean enable) {
    Component[] children = startContainer.getComponents();
    for (Component child : children) {
        if (child instanceof Container) {
            disOrEnableAllElements((Container) child, enable);
        }
        child.setEnabled(enable);
    }
}

From source file:SuitaDetails.java

public void setEnabled(boolean enabled) {
    for (Component component : definitions)
        component.setEnabled(enabled);
    for (Component component : defsContainer.getComponents())
        component.setEnabled(enabled);/*from  w w w .  jav a2  s. c  om*/
    for (Component component : global.getComponents())
        component.setEnabled(enabled);
    for (Component component : suiteoptions.getComponents())
        component.setEnabled(enabled);
    for (Component component : tcoptions.getComponents())
        component.setEnabled(enabled);
    combo.setEnabled(enabled);
    defsContainer.setEnabled(enabled);
    global.setEnabled(enabled);
    suiteoptions.setEnabled(enabled);
    tcoptions.setEnabled(enabled);
    if (enabled) {
        if (getItemParent() == null) {
            setTitle("Global options");
            scroll.setViewportView(global);
        } else if (getItemParent().getType() == 2) {
            setSuiteDetails(getItemParent().getPos().size() == 1);
        } else if (getItemParent().getType() == 1) {
            setTCDetails();
        }
    } else {
        System.out.println(getPreferredSize().getWidth());
        setTitle("Summary");
        scroll.setViewportView(summary);
        revalidate();
        repaint();
    }
}

From source file:edu.ku.brc.af.ui.forms.validation.FormValidator.java

/**
 * @param comp/*from  w  w  w . j  a v a  2 s  .  c o m*/
 * @param type
 */
public void addEnableItem(final Component comp, final EnableType type) {

    Vector<Component> list = enableHash.get(type);
    list.add(comp);
    comp.setEnabled(false);
}

From source file:oct.analysis.application.OCTAnalysisUI.java

public void enableAnalysisTools() {
    for (Component c : toolsMenu.getMenuComponents()) {
        c.setEnabled(true);
    }/*  ww w .  j av  a 2 s .  c  o  m*/
    for (Component c : analysisToolsToolBar.getComponents()) {
        c.setEnabled(true);
    }
}