Example usage for javax.swing JPanel setEnabled

List of usage examples for javax.swing JPanel setEnabled

Introduction

In this page you can find the example usage for javax.swing JPanel setEnabled.

Prototype

@BeanProperty(expert = true, preferred = true, visualUpdate = true, description = "The enabled state of the component.")
public void setEnabled(boolean enabled) 

Source Link

Document

Sets whether or not this component is enabled.

Usage

From source file:de.quadrillenschule.azocamsyncd.gui.ConfigurationWizardJFrame.java

public void updateSelectedPanel(int i) {
    String resource = "/de/quadrillenschule/azocamsyncd/ftpservice/res/step" + i + ".html";
    selectedPanel = i;//from   ww  w  .  j  a v a2  s. c o  m

    for (JPanel j : stepPanels) {
        j.setEnabled(false);
        j.setBackground(Color.lightGray);

    }
    stepPanels.get(i).setEnabled(true);
    stepPanels.get(i).setBackground(Color.white);
    showDocument(resource);
}

From source file:com.lottery.gui.MainLotteryForm.java

private void setPanelEnabled(JPanel panel, Boolean isEnabled) {
    panel.setEnabled(isEnabled);

    for (int i = 0; i < panel.getComponents().length; i++) {
        JComponent component = (JComponent) panel.getComponents()[i];
        if (component.getClass().getName() == "javax.swing.JPanel") {
            setPanelEnabled((JPanel) component, isEnabled);
        }// w w w  . j a  v a  2 s. co  m

        component.setEnabled(isEnabled);
    }
}

From source file:cool.pandora.modeller.ui.jpanel.base.SaveBagFrame.java

private JPanel createComponents() {
    final Border border = new EmptyBorder(5, 5, 5, 5);

    final TitlePane titlePane = new TitlePane();
    initStandardCommands();//  w  w w  . ja va2  s  .  com
    final JPanel pageControl = new JPanel(new BorderLayout());
    final JPanel titlePaneContainer = new JPanel(new BorderLayout());
    titlePane.setTitle(bagView.getPropertyMessage("SaveBagFrame.title"));
    titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Define the Bag " + "settings")));
    titlePaneContainer.add(titlePane.getControl());
    titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
    pageControl.add(titlePaneContainer, BorderLayout.NORTH);
    final JPanel contentPane = new JPanel();

    // TODO: Add bag name field
    // TODO: Add save name file selection button
    final JLabel location = new JLabel("Save in:");
    final JButton browseButton = new JButton(getMessage("bag.button.browse"));
    browseButton.addActionListener(new SaveBagAsHandler());
    browseButton.setEnabled(true);
    browseButton.setToolTipText(getMessage("bag.button.browse.help"));
    final DefaultBag bag = bagView.getBag();
    if (bag != null) {
        bagNameField = new JTextField(bag.getName());
        bagNameField.setCaretPosition(bag.getName().length());
        bagNameField.setEditable(false);
        bagNameField.setEnabled(false);
    }

    // Holey bag control
    final JLabel holeyLabel = new JLabel(bagView.getPropertyMessage("bag.label.isholey"));
    holeyLabel.setToolTipText(bagView.getPropertyMessage("bag.isholey.help"));
    final JCheckBox holeyCheckbox = new JCheckBox(bagView.getPropertyMessage("bag.checkbox" + ".isholey"));
    holeyCheckbox.setBorder(border);
    holeyCheckbox.addActionListener(new HoleyBagHandler());
    holeyCheckbox.setToolTipText(bagView.getPropertyMessage("bag.isholey.help"));

    urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label"));
    urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description"));
    urlField = new JTextField("");
    try {
        assert bag != null;
        urlField.setText(bag.getFetch().getBaseURL());
    } catch (Exception e) {
        log.error("Failed to set url label", e);
    }
    urlField.setEnabled(false);

    // TODO: Add format label
    final JLabel serializeLabel;
    serializeLabel = new JLabel(getMessage("bag.label.ispackage"));
    serializeLabel.setToolTipText(getMessage("bag.serializetype.help"));

    // TODO: Add format selection panel
    noneButton = new JRadioButton(getMessage("bag.serializetype.none"));
    noneButton.setEnabled(true);
    final AbstractAction serializeListener = new SerializeBagHandler();
    noneButton.addActionListener(serializeListener);
    noneButton.setToolTipText(getMessage("bag.serializetype.none.help"));

    zipButton = new JRadioButton(getMessage("bag.serializetype.zip"));
    zipButton.setEnabled(true);
    zipButton.addActionListener(serializeListener);
    zipButton.setToolTipText(getMessage("bag.serializetype.zip.help"));

    /*
     * tarButton = new JRadioButton(getMessage("bag.serializetype.tar"));
     * tarButton.setEnabled(true);
     * tarButton.addActionListener(serializeListener);
     * tarButton.setToolTipText(getMessage("bag.serializetype.tar.help"));
     *
     * tarGzButton = new JRadioButton(getMessage("bag.serializetype.targz"));
     * tarGzButton.setEnabled(true);
     * tarGzButton.addActionListener(serializeListener);
     * tarGzButton.setToolTipText(getMessage("bag.serializetype.targz.help"));
     *
     * tarBz2Button = new JRadioButton(getMessage("bag.serializetype.tarbz2"));
     * tarBz2Button.setEnabled(true);
     * tarBz2Button.addActionListener(serializeListener);
     * tarBz2Button.setToolTipText(getMessage("bag.serializetype.tarbz2.help"));
     */

    short mode = 2;
    if (bag != null) {
        mode = bag.getSerialMode();
    }
    if (mode == DefaultBag.NO_MODE) {
        this.noneButton.setEnabled(true);
    } else if (mode == DefaultBag.ZIP_MODE) {
        this.zipButton.setEnabled(true);
    } else {
        this.noneButton.setEnabled(true);
    }

    final ButtonGroup serializeGroup = new ButtonGroup();
    serializeGroup.add(noneButton);
    serializeGroup.add(zipButton);
    // serializeGroup.add(tarButton);
    // serializeGroup.add(tarGzButton);
    // serializeGroup.add(tarBz2Button);
    final JPanel serializeGroupPanel = new JPanel(new FlowLayout());
    serializeGroupPanel.add(serializeLabel);
    serializeGroupPanel.add(noneButton);
    serializeGroupPanel.add(zipButton);
    // serializeGroupPanel.add(tarButton);
    // serializeGroupPanel.add(tarGzButton);
    // serializeGroupPanel.add(tarBz2Button);
    serializeGroupPanel.setBorder(border);
    serializeGroupPanel.setEnabled(true);
    serializeGroupPanel.setToolTipText(bagView.getPropertyMessage("bag.serializetype.help"));

    final JLabel tagLabel = new JLabel(getMessage("bag.label.istag"));
    tagLabel.setToolTipText(getMessage("bag.label.istag.help"));
    final JCheckBox isTagCheckbox = new JCheckBox();
    isTagCheckbox.setBorder(border);
    isTagCheckbox.addActionListener(new TagManifestHandler());
    isTagCheckbox.setToolTipText(getMessage("bag.checkbox.istag.help"));

    final JLabel tagAlgorithmLabel = new JLabel(getMessage("bag.label.tagalgorithm"));
    tagAlgorithmLabel.setToolTipText(getMessage("bag.label.tagalgorithm.help"));
    final ArrayList<String> listModel = new ArrayList<>();
    for (final Algorithm algorithm : Algorithm.values()) {
        listModel.add(algorithm.bagItAlgorithm);
    }
    final JComboBox<String> tagAlgorithmList = new JComboBox<>(listModel.toArray(new String[listModel.size()]));
    tagAlgorithmList.setName(getMessage("bag.tagalgorithmlist"));
    tagAlgorithmList.addActionListener(new TagAlgorithmListHandler());
    tagAlgorithmList.setToolTipText(getMessage("bag.tagalgorithmlist.help"));

    final JLabel payloadLabel = new JLabel(getMessage("bag.label.ispayload"));
    payloadLabel.setToolTipText(getMessage("bag.ispayload.help"));
    final JCheckBox isPayloadCheckbox = new JCheckBox();
    isPayloadCheckbox.setBorder(border);
    isPayloadCheckbox.addActionListener(new PayloadManifestHandler());
    isPayloadCheckbox.setToolTipText(getMessage("bag.ispayload.help"));

    final JLabel payAlgorithmLabel = new JLabel(bagView.getPropertyMessage("bag.label" + ".payalgorithm"));
    payAlgorithmLabel.setToolTipText(getMessage("bag.payalgorithm.help"));
    final JComboBox<String> payAlgorithmList = new JComboBox<String>(
            listModel.toArray(new String[listModel.size()]));
    payAlgorithmList.setName(getMessage("bag.payalgorithmlist"));
    payAlgorithmList.addActionListener(new PayAlgorithmListHandler());
    payAlgorithmList.setToolTipText(getMessage("bag.payalgorithmlist.help"));

    //only if bag is not null
    if (bag != null) {
        final String fileName = bag.getName();
        bagNameField = new JTextField(fileName);
        bagNameField.setCaretPosition(fileName.length());

        holeyCheckbox.setSelected(bag.isHoley());
        urlLabel.setEnabled(bag.isHoley());
        isTagCheckbox.setSelected(bag.isBuildTagManifest());
        tagAlgorithmList.setSelectedItem(bag.getTagManifestAlgorithm());
        isPayloadCheckbox.setSelected(bag.isBuildPayloadManifest());
        payAlgorithmList.setSelectedItem(bag.getPayloadManifestAlgorithm());
    }

    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints glbc = new GridBagConstraints();
    final JPanel panel = new JPanel(layout);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    int row = 0;

    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(location, glbc);
    panel.add(location);

    buildConstraints(glbc, 2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST);
    glbc.ipadx = 5;
    layout.setConstraints(browseButton, glbc);
    glbc.ipadx = 0;
    panel.add(browseButton);

    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    glbc.ipadx = 5;
    layout.setConstraints(bagNameField, glbc);
    glbc.ipadx = 0;
    panel.add(bagNameField);

    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(holeyLabel, glbc);
    panel.add(holeyLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.WEST, GridBagConstraints.WEST);
    layout.setConstraints(holeyCheckbox, glbc);
    panel.add(holeyCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(urlLabel, glbc);
    panel.add(urlLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(urlField, glbc);
    panel.add(urlField);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(serializeLabel, glbc);
    panel.add(serializeLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    layout.setConstraints(serializeGroupPanel, glbc);
    panel.add(serializeGroupPanel);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(tagLabel, glbc);
    panel.add(tagLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(isTagCheckbox, glbc);
    panel.add(isTagCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(tagAlgorithmLabel, glbc);
    panel.add(tagAlgorithmLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(tagAlgorithmList, glbc);
    panel.add(tagAlgorithmList);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(payloadLabel, glbc);
    panel.add(payloadLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(isPayloadCheckbox, glbc);
    panel.add(isPayloadCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(payAlgorithmLabel, glbc);
    panel.add(payAlgorithmLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(payAlgorithmList, glbc);
    panel.add(payAlgorithmList);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);

    GuiStandardUtils.attachDialogBorder(contentPane);
    pageControl.add(panel);
    final JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;

}