Example usage for javax.swing ButtonGroup ButtonGroup

List of usage examples for javax.swing ButtonGroup ButtonGroup

Introduction

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

Prototype

public ButtonGroup() 

Source Link

Document

Creates a new ButtonGroup.

Usage

From source file:components.DialogDemo.java

private JPanel createIconDialogBox() {
    JButton showItButton = null;// w w  w  . j a  v a 2s.  c o m

    final int numButtons = 6;
    JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();

    final String plainCommand = "plain";
    final String infoCommand = "info";
    final String questionCommand = "question";
    final String errorCommand = "error";
    final String warningCommand = "warning";
    final String customCommand = "custom";

    radioButtons[0] = new JRadioButton("Plain (no icon)");
    radioButtons[0].setActionCommand(plainCommand);

    radioButtons[1] = new JRadioButton("Information icon");
    radioButtons[1].setActionCommand(infoCommand);

    radioButtons[2] = new JRadioButton("Question icon");
    radioButtons[2].setActionCommand(questionCommand);

    radioButtons[3] = new JRadioButton("Error icon");
    radioButtons[3].setActionCommand(errorCommand);

    radioButtons[4] = new JRadioButton("Warning icon");
    radioButtons[4].setActionCommand(warningCommand);

    radioButtons[5] = new JRadioButton("Custom icon");
    radioButtons[5].setActionCommand(customCommand);

    for (int i = 0; i < numButtons; i++) {
        group.add(radioButtons[i]);
    }
    radioButtons[0].setSelected(true);

    showItButton = new JButton("Show it!");
    showItButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();

            //no icon
            if (command == plainCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "A plain message",
                        JOptionPane.PLAIN_MESSAGE);
                //information icon
            } else if (command == infoCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.",
                        "Inane informational dialog", JOptionPane.INFORMATION_MESSAGE);

                //XXX: It doesn't make sense to make a question with
                //XXX: only one button.
                //XXX: See "Yes/No (but not in those words)" for a better solution.
                //question icon
            } else if (command == questionCommand) {
                JOptionPane.showMessageDialog(frame,
                        "You shouldn't use a message dialog " + "(like this)\n" + "for a question, OK?",
                        "Inane question", JOptionPane.QUESTION_MESSAGE);
                //error icon
            } else if (command == errorCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane error",
                        JOptionPane.ERROR_MESSAGE);
                //warning icon
            } else if (command == warningCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane warning",
                        JOptionPane.WARNING_MESSAGE);
                //custom icon
            } else if (command == customCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane custom dialog",
                        JOptionPane.INFORMATION_MESSAGE, icon);
            }
        }
    });

    return create2ColPane(iconDesc + ":", radioButtons, showItButton);
}

From source file:eu.apenet.dpt.standalone.gui.ead2edm.EdmOptionsPanel.java

private void createOptionPanel() {
    labels = dataPreparationToolGUI.getLabels();
    JPanel creativeCommonsPanel = new CreativeCommonsPanel();
    JPanel europeanaRightsPanel = new EuropeanaRightsPanel();
    JPanel emptyPanel = new JPanel();

    JPanel formPanel = new JPanel(new GridLayout(14, 1));

    JPanel extraLicenseCardLayoutPanel = new JPanel(new CardLayout());
    extraLicenseCardLayoutPanel.add(creativeCommonsPanel, CREATIVE_COMMONS);
    extraLicenseCardLayoutPanel.add(europeanaRightsPanel, EUROPEANA_RIGHTS_STATEMENTS);
    extraLicenseCardLayoutPanel.add(emptyPanel, EMPTY_PANEL);
    CardLayout cardLayout = (CardLayout) extraLicenseCardLayoutPanel.getLayout();
    cardLayout.show(extraLicenseCardLayoutPanel, EMPTY_PANEL);

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    conversionModeGroup = new ButtonGroup();
    JRadioButton radioButton;/*from w  w  w.j  a v a2s  .  c o  m*/

    panel.add(new Label(this.labels.getString("edm.panel.label.choose.mode")));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.minimal"));
    radioButton.setActionCommand(MINIMAL);
    radioButton.setSelected(true);
    radioButton.addActionListener(new ConversionModeListener());
    conversionModeGroup.add(radioButton);
    panel.add(radioButton);
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.full"));
    radioButton.setActionCommand(FULL);
    radioButton.addActionListener(new ConversionModeListener());
    conversionModeGroup.add(radioButton);
    panel.add(radioButton);

    formPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    cLevelIdSourceButtonGroup = new ButtonGroup();

    panel.add(new Label(this.labels.getString("edm.generalOptionsForm.identifierSource.header")));
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.unitid"));
    radioButton.setActionCommand(UNITID);
    if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) {
        radioButton.setSelected(true);
    }
    cLevelIdSourceButtonGroup.add(radioButton);
    panel.add(radioButton);
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.cid"));
    radioButton.setActionCommand(CID);
    if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) {
        radioButton.setSelected(true);
    }
    cLevelIdSourceButtonGroup.add(radioButton);
    panel.add(radioButton);

    formPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    sourceOfFondsTitleGroup = new ButtonGroup();

    determineDaoInformation();
    panel.add(new Label(this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle")));
    if (!this.batch && StringUtils.isBlank(ead2EdmInformation.getArchdescUnittitle())
            && StringUtils.isBlank(ead2EdmInformation.getTitlestmtTitleproper())) {
        panel.add(new Label(
                this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.noSourceAvailable")));
    } else {
        radioButton = new JRadioButton(
                this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.archdescUnittitle"));
        radioButton.setActionCommand(ARCHDESC_UNITTITLE);
        radioButton.setSelected(true);
        radioButton.addActionListener(new ConversionModeListener());
        sourceOfFondsTitleGroup.add(radioButton);
        panel.add(radioButton);
        radioButton = new JRadioButton(
                this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.titlestmtTitleproper"));
        radioButton.setActionCommand(TITLESTMT_TITLEPROPER);
        radioButton.addActionListener(new ConversionModeListener());
        sourceOfFondsTitleGroup.add(radioButton);
        panel.add(radioButton);
    }
    formPanel.add(panel);

    panel = new JPanel(new GridLayout(2, 2));
    landingPageButtonGroup = new ButtonGroup();

    panel.add(new Label(this.labels.getString("edm.generalOptionsForm.landingPages.header")));
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.ape"));
    radioButton.setActionCommand(APE);
    if (retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) {
        radioButton.setSelected(true);
    }
    landingPageButtonGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new Label());
    JPanel otherPanel = new JPanel(new GridLayout(1, 2));
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.other"));
    radioButton.setActionCommand(OTHER);
    landingPageButtonGroup.add(radioButton);
    otherPanel.add(radioButton);
    landingPageTextArea = new JTextArea();
    landingPageTextArea.setLineWrap(true);
    landingPageTextArea.setWrapStyleWord(true);
    if (!retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) {
        radioButton.setSelected(true);
        landingPageTextArea.setText(retrieveFromDb.retrieveLandingPageBase());
    }
    JScrollPane lptaScrollPane = new JScrollPane(landingPageTextArea);
    lptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    otherPanel.add(lptaScrollPane);
    panel.add(otherPanel);

    formPanel.add(panel);

    panel = new JPanel(new GridLayout(1, 1));
    panel.add(new Label(labels.getString("ese.mandatoryFieldsInfo")));
    panel.add(new Label(""));
    panel.setBorder(BLACK_LINE);
    formPanel.add(panel);

    panel = new JPanel(new GridLayout(1, 3));
    panel.add(new Label(labels.getString("ese.dataProvider") + ":" + "*"));
    dataProviderTextArea = new JTextArea();
    dataProviderTextArea.setLineWrap(true);
    dataProviderTextArea.setWrapStyleWord(true);
    JScrollPane dptaScrollPane = new JScrollPane(dataProviderTextArea);
    dptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    panel.add(dptaScrollPane);
    useExistingRepoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileRepository"));
    useExistingRepoCheckbox.setSelected(true);
    useExistingRepoCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            //empty method on purpose
        }
    });
    JPanel panel2 = new JPanel(new GridLayout(1, 1));
    panel2.add(useExistingRepoCheckbox);
    if (!batch) {
        String repository = ead2EdmInformation.getRepository();
        if (repository != null && !repository.equals("")) {
            dataProviderTextArea.setText(repository);
        } else {
            if (archdescRepository != null) {
                dataProviderTextArea.setText(archdescRepository);
            } else {
                useExistingRepoCheckbox.setSelected(false);
            }
        }
    }
    panel.add(panel2);
    panel.setBorder(BLACK_LINE);
    formPanel.add(panel);

    /*        panel = new JPanel(new GridLayout(1, 3));
     panel.add(new Label(labels.getString("ese.provider") + ":" + "*"));
     providerTextArea = new JTextArea();
     providerTextArea.setLineWrap(true);
     providerTextArea.setWrapStyleWord(true);
     JScrollPane ptaScrollPane = new JScrollPane(providerTextArea);
     ptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
     panel.add(ptaScrollPane);
     panel.add(new Label(""));
     panel.setBorder(BLACK_LINE);
     formPanel.add(panel);
     */
    panel = new JPanel(new GridLayout(5, 3));
    typeGroup = new ButtonGroup();

    panel.add(new Label(labels.getString("ese.type") + ":" + "*"));
    String currentRoleType;
    if (batch) {
        currentRoleType = "";
    } else {
        currentRoleType = ead2EdmInformation.getRoleType();
    }
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.text"));
    if (currentRoleType.equals(EdmOptionsPanel.TEXT)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(TEXT);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.image"));
    if (currentRoleType.equals(EdmOptionsPanel.IMAGE)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(IMAGE);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.video"));
    if (currentRoleType.equals(EdmOptionsPanel.VIDEO)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(VIDEO);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);

    useExistingDaoRoleCheckbox = new JCheckBox(labels.getString("ese.takeFromFileDaoRole"));
    useExistingDaoRoleCheckbox.setSelected(true);
    useExistingDaoRoleCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
        }
    });
    panel.add(useExistingDaoRoleCheckbox);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.sound"));
    if (currentRoleType.equals(EdmOptionsPanel.SOUND)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(SOUND);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.threed"));
    if (currentRoleType.equals(EdmOptionsPanel.THREE_D)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(THREE_D);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.setBorder(GREY_LINE);
    formPanel.add(panel);

    if (this.batch) {
        panel = new JPanel(new GridLayout(1, 3));
        panel.add(new Label(labels.getString("ese.selectLanguage") + ":" + "*"));
        panel.add(languageBoxPanel);
        useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage"));
        useExistingLanguageCheckbox.setSelected(true);
        useExistingLanguageCheckbox.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                //empty method on purpose
            }
        });
        panel.add(useExistingLanguageCheckbox);
        panel.setBorder(BLACK_LINE);
        formPanel.add(panel);
    } else {
        inheritLanguagePanel = new JPanel(new GridLayout(1, 3));
        inheritLanguagePanel.add(new Label(labels.getString("ese.inheritLanguage") + ":" + "*"));

        JPanel rbPanel = new JPanel(new GridLayout(4, 1));
        inheritLanguageGroup = new ButtonGroup();
        inhLanYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
        inhLanYesRadioButton.setActionCommand(YES);
        inhLanYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
        inheritLanguageGroup.add(inhLanYesRadioButton);
        rbPanel.add(inhLanYesRadioButton);
        inhLanNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
        inhLanNoRadioButton.setActionCommand(NO);
        inhLanNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
        inheritLanguageGroup.add(inhLanNoRadioButton);
        rbPanel.add(inhLanNoRadioButton);
        inhLanProvideRadioButton = new JRadioButton(labels.getString("ese.provide"));
        inhLanProvideRadioButton.setActionCommand(PROVIDE);
        inhLanProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
        inheritLanguageGroup.add(inhLanProvideRadioButton);
        rbPanel.add(inhLanProvideRadioButton);
        useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage"));
        useExistingLanguageCheckbox.setSelected(true);
        useExistingLanguageCheckbox.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                //empty method on purpose
            }
        });
        rbPanel.add(useExistingLanguageCheckbox);
        inheritLanguagePanel.add(rbPanel, BorderLayout.WEST);

        languageBoxPanel.setVisible(true);
        inheritLanguagePanel.add(languageBoxPanel, BorderLayout.EAST);
        inheritLanguagePanel.setBorder(BLACK_LINE);
        inheritLanguagePanel.setVisible(true);
        formPanel.add(inheritLanguagePanel);
    }

    //        if (this.batch) {
    panel = new JPanel(new GridLayout(1, 3));
    panel.add(new JLabel(labels.getString("edm.panel.license.inheritLicense") + ":" + "*"));
    useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense"));
    useExistingRightsInfoCheckbox.setSelected(true);
    useExistingRightsInfoCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            //empty method on purpose
        }
    });
    panel.add(useExistingRightsInfoCheckbox);
    panel.add(new JLabel());
    panel.setBorder(BLACK_LINE);
    panel.setVisible(true);
    formPanel.add(panel);
    //        } else {
    //            panel = new JPanel(new GridLayout(3, 3));
    //            inheritLicenseGroup = new ButtonGroup();
    //
    //            panel.add(new Label(labels.getString("edm.panel.license.inheritLicense") + ":" + "*"));
    //            inhLicYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    //            inhLicYesRadioButton.setActionCommand(YES);
    ////        inhLicYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
    //            inheritLicenseGroup.add(inhLicYesRadioButton);
    //            panel.add(inhLicYesRadioButton);
    //            panel.add(new JLabel());
    //
    //            panel.add(new JLabel());
    //            inhLicNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    //            inhLicNoRadioButton.setActionCommand(NO);
    ////        inhLicNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
    //            inheritLicenseGroup.add(inhLicNoRadioButton);
    //            panel.add(inhLicNoRadioButton);
    //            useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense"));
    //            useExistingRightsInfoCheckbox.setSelected(true);
    //            useExistingRightsInfoCheckbox.addItemListener(new ItemListener() {
    //                @Override
    //                public void itemStateChanged(ItemEvent e) {
    //                    //empty method on purpose
    //                }
    //            });
    //
    //            panel.add(useExistingRightsInfoCheckbox);
    //
    //            panel.add(new JLabel());
    //            inhLicProvideRadioButton = new JRadioButton(labels.getString("ese.provide"));
    //            inhLicProvideRadioButton.setActionCommand(PROVIDE);
    ////        inhLicProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
    //            inheritLicenseGroup.add(inhLicProvideRadioButton);
    //            panel.add(inhLicProvideRadioButton);
    //            panel.add(new JLabel());
    //
    //            panel.setBorder(BLACK_LINE);
    //            panel.setVisible(true);
    //            formPanel.add(panel);
    //        }

    JPanel mainLicensePanel = new JPanel(new BorderLayout());
    panel = new JPanel(new GridLayout(5, 2));
    licenseGroup = new ButtonGroup();
    //        String currentRightsInformation;
    //        if (batch) {
    //            currentRightsInformation = "";
    //        } else {
    //            currentRightsInformation = ead2EdmInformation.getArchdescLicenceType();
    //        }

    panel.add(new Label(labels.getString("ese.specifyLicense") + ":" + "*"));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(CREATIVE_COMMONS);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.zero"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_CC0)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(CREATIVE_COMMONS_CC0);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.public"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.europeana.rights"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(EUROPEANA_RIGHTS_STATEMENTS);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.out.copyright"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.OUT_OF_COPYRIGHT)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(EdmOptionsPanel.OUT_OF_COPYRIGHT);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);
    mainLicensePanel.add(panel, BorderLayout.WEST);

    mainLicensePanel.add(extraLicenseCardLayoutPanel, BorderLayout.EAST);
    //        if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS) || currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) {
    //            cardLayout.show(extraLicenseCardLayoutPanel, currentRightsInformation);
    //            if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) {
    //                if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-f/")) {
    //                    europeanaRightsComboBox.setSelectedIndex(0);
    //                } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("orphan-work-eu/")) {
    //                    europeanaRightsComboBox.setSelectedIndex(1);
    //                } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-p/")) {
    //                    europeanaRightsComboBox.setSelectedIndex(2);
    //                } else {
    //                    europeanaRightsComboBox.setSelectedIndex(3);
    //                }
    //            } else if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) {
    //                // get respective items from EAD2EDMInfo and set panel items appropriately
    //            }
    //        }
    mainLicensePanel.setBorder(BLACK_LINE);
    formPanel.add(mainLicensePanel);

    panel = new JPanel(new GridLayout(1, 1));
    panel.add(new Label(labels.getString("ese.specifyAdditionalRightsInfo") + ":"));
    additionalRightsTextArea = new JTextArea();
    additionalRightsTextArea.setLineWrap(true);
    additionalRightsTextArea.setWrapStyleWord(true);
    JScrollPane artaScrollPane = new JScrollPane(additionalRightsTextArea);
    artaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    panel.add(artaScrollPane);
    panel.setBorder(GREY_LINE);
    formPanel.add(panel);

    inheritParentPanel = new JPanel(new GridLayout(2, 3));
    inheritParentCheckbox = new JCheckBox(labels.getString("ese.inheritParent") + ":" + "*");
    inheritParentCheckbox.setSelected(true);
    inheritParentCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                inhParYesRadioButton.setEnabled(true);
                inhParNoRadioButton.setEnabled(true);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                inhParYesRadioButton.setEnabled(false);
                inhParNoRadioButton.setEnabled(false);
            }
        }
    });
    inheritParentPanel.add(inheritParentCheckbox);
    inheritParentGroup = new ButtonGroup();
    inhParYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    inhParYesRadioButton.setActionCommand(YES);
    inheritParentGroup.add(inhParYesRadioButton);
    inheritParentPanel.add(inhParYesRadioButton);
    inheritParentPanel.add(new JLabel(""));
    inhParNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    inhParNoRadioButton.setActionCommand(NO);
    inheritParentGroup.add(inhParNoRadioButton);
    inheritParentPanel.add(inhParNoRadioButton);
    inheritParentPanel.setBorder(GREY_LINE);
    inheritParentPanel.setVisible(false);
    formPanel.add(inheritParentPanel);

    inheritOriginationPanel = new JPanel(new GridLayout(2, 3));
    inheritOriginationCheckbox = new JCheckBox(labels.getString("ese.inheritOrigination") + ":" + "*");
    inheritOriginationCheckbox.setSelected(true);
    inheritOriginationCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                inhOriYesRadioButton.setEnabled(true);
                inhOriNoRadioButton.setEnabled(true);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                inhOriYesRadioButton.setEnabled(false);
                inhOriNoRadioButton.setEnabled(false);
            }
        }
    });
    inheritOriginationPanel.add(inheritOriginationCheckbox);
    inheritOriginationGroup = new ButtonGroup();
    inhOriYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    inhOriYesRadioButton.setActionCommand(YES);
    inheritOriginationGroup.add(inhOriYesRadioButton);
    inheritOriginationPanel.add(inhOriYesRadioButton);
    inheritOriginationPanel.add(new JLabel(""));
    inhOriNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    inhOriNoRadioButton.setActionCommand(NO);
    inheritOriginationGroup.add(inhOriNoRadioButton);
    inheritOriginationPanel.add(inhOriNoRadioButton);
    inheritOriginationPanel.setBorder(BLACK_LINE);
    inheritOriginationPanel.setVisible(false);
    formPanel.add(inheritOriginationPanel);

    inheritUnittitlePanel = new JPanel(new GridLayout(2, 3));
    inheritUnittitleCheckbox = new JCheckBox(labels.getString("ese.inheritUnittitle") + ":" + "*");
    inheritUnittitleCheckbox.setSelected(true);
    inheritUnittitleCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                inhTitleYesRadioButton.setEnabled(true);
                inhTitleNoRadioButton.setEnabled(true);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                inhTitleYesRadioButton.setEnabled(false);
                inhTitleNoRadioButton.setEnabled(false);
            }
        }
    });
    inheritUnittitlePanel.add(inheritUnittitleCheckbox);
    inheritUnittitleGroup = new ButtonGroup();
    inhTitleYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    inhTitleYesRadioButton.setActionCommand(YES);
    inheritUnittitleGroup.add(inhTitleYesRadioButton);
    inheritUnittitlePanel.add(inhTitleYesRadioButton);
    inheritUnittitlePanel.add(new JLabel(""));
    inhTitleNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    inhTitleNoRadioButton.setActionCommand(NO);
    inheritUnittitleGroup.add(inhTitleNoRadioButton);
    inheritUnittitlePanel.add(inhTitleNoRadioButton);
    inheritUnittitlePanel.setBorder(BLACK_LINE);
    inheritUnittitlePanel.setVisible(false);
    formPanel.add(inheritUnittitlePanel);

    JButton createEdmBtn = new JButton(labels.getString("ese.createEseBtn"));
    JButton cancelBtn = new JButton(labels.getString("ese.cancelBtn"));

    createEdmBtn.addActionListener(new CreateEdmActionListener());
    cancelBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (Map.Entry<String, FileInstance> entry : fileInstances.entrySet()) {
                FileInstance fileInstance = entry.getValue();
                fileInstance.setEdm(false);
            }
            dataPreparationToolGUI.enableEdmConversionBtn();
            if (batch) {
                dataPreparationToolGUI.enableAllBatchBtns();
            }
            dataPreparationToolGUI.enableRadioButtons();
            close();
        }
    });

    JPanel buttonPanel = new JPanel(new GridLayout(1, 5));

    buttonPanel.add(new JLabel(""));
    buttonPanel.add(cancelBtn);
    buttonPanel.add(new JLabel(""));
    buttonPanel.add(createEdmBtn);
    buttonPanel.add(new JLabel(""));

    add(formPanel, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
}

From source file:LightBug.java

JPanel lightPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(0, 1));

    panel.add(new JLabel("Light type"));

    // create the buttons
    JRadioButton lightNoneButton = new JRadioButton(lightNoneString);
    JRadioButton lightDirectionalButton = new JRadioButton(lightDirectionalString);
    JRadioButton lightPointButton = new JRadioButton(lightPointString);
    JRadioButton lightSpotButton = new JRadioButton(lightSpotString);

    // set up the action commands
    lightNoneButton.setActionCommand(lightNoneString);
    lightDirectionalButton.setActionCommand(lightDirectionalString);
    lightPointButton.setActionCommand(lightPointString);
    lightSpotButton.setActionCommand(lightSpotString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(lightNoneButton);//from w  ww .j  a  va 2 s  .  c o  m
    buttonGroup.add(lightDirectionalButton);
    buttonGroup.add(lightPointButton);
    buttonGroup.add(lightSpotButton);

    // register the applet as the listener for the buttons
    lightNoneButton.addActionListener(this);
    lightDirectionalButton.addActionListener(this);
    lightPointButton.addActionListener(this);
    lightSpotButton.addActionListener(this);

    // add the buttons to the panel
    panel.add(lightNoneButton);
    panel.add(lightDirectionalButton);
    panel.add(lightPointButton);
    panel.add(lightSpotButton);

    // set the default
    lightDirectionalButton.setSelected(true);

    return panel;
}

From source file:org.gumtree.vis.awt.time.TimePlotChartEditor.java

private JPanel createCordinatePanel() {
    JPanel wrap = new JPanel(new BorderLayout());
    JPanel coordinate = new JPanel(new GridLayout(2, 1));
    coordinate.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    //Horizontal group
    JPanel horizontal = new JPanel(new BorderLayout());
    horizontal.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Time Axis"));

    JPanel inner = new JPanel(new LCBLayout(6));
    inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    ButtonGroup axisControlGroup = new ButtonGroup();

    showAllHistory = new JRadioButton("Show all history");
    showAllHistory.setActionCommand(SHOW_ALL_HISTORY_COMMAND);
    showAllHistory.addActionListener(this);
    inner.add(showAllHistory);/*from w w  w .  j  a  v a  2  s. com*/
    inner.add(new JLabel());
    inner.add(new JLabel());
    //
    showPartHistory = new JRadioButton("Fix time range");
    showPartHistory.setActionCommand(FIXED_LENGTH_HISTORY_COMMAND);
    showPartHistory.addActionListener(this);
    inner.add(showPartHistory);
    timeField = new JTextField(5);
    inner.add(timeField);
    inner.add(new JLabel("seconds"));
    axisControlGroup.add(showAllHistory);
    axisControlGroup.add(showPartHistory);

    horizontal.add(inner, BorderLayout.NORTH);

    //Vertical group
    //       JPanel vertical = new JPanel(new BorderLayout());
    //       vertical.setBorder(BorderFactory.createTitledBorder(
    //            BorderFactory.createEtchedBorder(), "Vertical Axis"));
    //
    //       inner = new JPanel(new LCBLayout(6));
    //      inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    //      inner.add(new JLabel("Logarithm Y Axis"));
    //      logarithmY = new JCheckBox();
    //      logarithmY.setActionCommand(LOGARITHM_Y_AXIS_COMMAND);
    //      logarithmY.addActionListener(this);
    //      inner.add(logarithmY);
    //      inner.add(new JLabel());
    //
    //      inner.add(new JLabel("Flip Y Axis"));
    //      flipY = new JCheckBox();
    //      flipY.setActionCommand(FLIP_Y_AXIS_COMMAND);
    //      flipY.addActionListener(this);
    //      inner.add(flipY);
    //      inner.add(new JLabel());

    //       vertical.add(inner, BorderLayout.NORTH);

    coordinate.add(horizontal, BorderLayout.NORTH);
    //      coordinate.add(vertical);
    wrap.setName("Coordinate");
    wrap.add(coordinate, BorderLayout.NORTH);
    return wrap;
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDoseResponseController.java

/**
 * Initialize main view/*  w  w  w  . j a va  2  s. c o  m*/
 */
@Override
protected void initMainView() {
    genericDRParentPanel = new GenericDRParentPanel();
    dRPanel = new DRPanel();
    //buttons disabled at start
    genericDRParentPanel.getCancelButton().setEnabled(false);
    genericDRParentPanel.getNextButton().setEnabled(false);
    getCardLayout().first(genericDRParentPanel.getContentPanel());
    onCardSwitch();
    //create a ButtonGroup for the radioButtons used for analysis
    ButtonGroup mainDRRadioButtonGroup = new ButtonGroup();
    //adding buttons to a ButtonGroup automatically deselect one when another one gets selected
    mainDRRadioButtonGroup.add(dRPanel.getInputDRButton());
    mainDRRadioButtonGroup.add(dRPanel.getInitialPlotDRButton());
    mainDRRadioButtonGroup.add(dRPanel.getNormalizedPlotDRButton());
    mainDRRadioButtonGroup.add(dRPanel.getResultsDRButton());
    //select as default first button
    dRPanel.getInputDRButton().setSelected(true);
    //init dataTable
    dataTable = new JTable();
    JScrollPane scrollPane = new JScrollPane(dataTable);
    //the table will take all the viewport height available
    dataTable.setFillsViewportHeight(true);
    scrollPane.getViewport().setBackground(Color.white);
    dataTable.getTableHeader().setReorderingAllowed(false);
    //row and column selection must be false
    //dataTable.setColumnSelectionAllowed(false);
    //dataTable.setRowSelectionAllowed(false);
    dRPanel.getDatatableDRPanel().add(scrollPane, BorderLayout.CENTER);
    setLogTransform(true);

    /**
     * Action listeners for uppermost panel.
     */
    //this button is ONLY used when going from the loading to the analysis
    genericDRParentPanel.getNextButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            genericDRParentPanel.getNextButton().setEnabled(false);
            genericDRParentPanel.getCancelButton().setEnabled(true);
            //save any metadata that was provided manually
            loadGenericDRDataController.setManualMetaData(importedDRDataHolder);
            //switch between child panels
            getCardLayout().next(genericDRParentPanel.getContentPanel());
            onCardSwitch();
        }
    });

    genericDRParentPanel.getCancelButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // warn the user and reset everything
            Object[] options = { "Yes", "No" };
            int showOptionDialog = JOptionPane.showOptionDialog(null,
                    "Current analysis won't be saved. Continue?", "", JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[1]);
            if (showOptionDialog == 0) {
                // reset everything
                resetOnCancel();
            }
        }
    });

    /**
     * Action listeners for shared panel. When button is selected, switch
     * view to corresponding subview
     */
    dRPanel.getInputDRButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //switch shared table view
            updateModelInTable(dRInputController.getTableModel());
            updateTableInfoMessage("This table contains all conditions and their respective responses");
            /**
             * for (int columnIndex = 0; columnIndex <
             * dataTable.getColumnCount(); columnIndex++) {
             * GuiUtils.packColumn(dataTable, columnIndex); }
             */
            dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT));
            //remove other panels
            dRInitialController.getInitialChartPanel().setChart(null);
            dRNormalizedController.getNormalizedChartPanel().setChart(null);
            dRResultsController.getDupeInitialChartPanel().setChart(null);
            dRResultsController.getDupeNormalizedChartPanel().setChart(null);
            dRPanel.getGraphicsDRParentPanel().removeAll();
            dRPanel.getGraphicsDRParentPanel().revalidate();
            dRPanel.getGraphicsDRParentPanel().repaint();
            //add panel to view
            dRPanel.getGraphicsDRParentPanel().add(dRInputController.getdRInputPanel(), gridBagConstraints);
        }
    });

    dRPanel.getInitialPlotDRButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (dRAnalysisGroup != null) {
                if (isFirstFitting()) {
                    initFirstFitting();
                    setFirstFitting(false);
                }
                //switch shared table view
                updateModelInTable(dRInitialController.getTableModel());
                updateTableInfoMessage(
                        "If you checked the box at the import screen, the doses have been log-transformed. Responses have not been changed");
                /**
                 * for (int columnIndex = 0; columnIndex <
                 * dataTable.getColumnCount(); columnIndex++) {
                 * GuiUtils.packColumn(dataTable, columnIndex); }
                 */
                dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT));
                //remove other panels
                dRNormalizedController.getNormalizedChartPanel().setChart(null);
                dRResultsController.getDupeInitialChartPanel().setChart(null);
                dRResultsController.getDupeNormalizedChartPanel().setChart(null);
                dRPanel.getGraphicsDRParentPanel().removeAll();
                dRPanel.getGraphicsDRParentPanel().revalidate();
                dRPanel.getGraphicsDRParentPanel().repaint();
                dRPanel.getGraphicsDRParentPanel().add(dRInitialController.getDRInitialPlotPanel(),
                        gridBagConstraints);
                //Plot fitted data in dose-response curve, along with R annotation
                plotDoseResponse(dRInitialController.getInitialChartPanel(),
                        dRInitialController.getDRInitialPlotPanel().getDoseResponseChartParentPanel(),
                        getDataToFit(false), getdRAnalysisGroup(), false);
            }
        }
    });

    dRPanel.getNormalizedPlotDRButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (dRAnalysisGroup != null) {
                //in case user skips "initial" subview and goes straight to normalization
                if (isFirstFitting()) {
                    initFirstFitting();
                    setFirstFitting(false);
                }
                //switch shared table view
                updateModelInTable(dRNormalizedController.getTableModel());
                updateTableInfoMessage(
                        "Potentially log-transformed doses with their normalized responses per replicate");
                /**
                 * for (int columnIndex = 0; columnIndex <
                 * dataTable.getColumnCount(); columnIndex++) {
                 * GuiUtils.packColumn(dataTable, columnIndex); }
                 */
                dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT));
                //remove other panels
                dRInitialController.getInitialChartPanel().setChart(null);
                dRResultsController.getDupeInitialChartPanel().setChart(null);
                dRResultsController.getDupeNormalizedChartPanel().setChart(null);
                dRPanel.getGraphicsDRParentPanel().removeAll();
                dRPanel.getGraphicsDRParentPanel().revalidate();
                dRPanel.getGraphicsDRParentPanel().repaint();
                dRPanel.getGraphicsDRParentPanel().add(dRNormalizedController.getDRNormalizedPlotPanel(),
                        gridBagConstraints);
                //Plot fitted data in dose-response curve, along with R annotation
                plotDoseResponse(dRNormalizedController.getNormalizedChartPanel(),
                        dRNormalizedController.getDRNormalizedPlotPanel().getDoseResponseChartParentPanel(),
                        getDataToFit(true), getdRAnalysisGroup(), true);
            }
        }
    });

    dRPanel.getResultsDRButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (dRAnalysisGroup != null) {
                //switch shared table view: create and set new table model with most recent statistical values
                // (these values get recalculated after each new fitting)
                dRResultsController.setTableModel(dRResultsController.reCreateTableModel(dRAnalysisGroup));
                updateModelInTable(dRResultsController.getTableModel());
                updateTableInfoMessage(
                        "Statistical values from the curve fit of the initial and normalized data.");

                //remove other panels
                dRInitialController.getInitialChartPanel().setChart(null);
                dRNormalizedController.getNormalizedChartPanel().setChart(null);
                dRPanel.getGraphicsDRParentPanel().removeAll();
                dRPanel.getGraphicsDRParentPanel().revalidate();
                dRPanel.getGraphicsDRParentPanel().repaint();
                dRPanel.getGraphicsDRParentPanel().add(dRResultsController.getdRResultsPanel(),
                        gridBagConstraints);
                //plot curves
                dRResultsController.plotCharts();
            }
        }
    });

    //add views to parent panels
    cellMissyController.getCellMissyFrame().getDoseResponseAnalysisParentPanel().add(genericDRParentPanel,
            gridBagConstraints);
    genericDRParentPanel.getDataLoadingPanel().add(loadGenericDRDataController.getDataLoadingPanel(),
            gridBagConstraints);
    genericDRParentPanel.getDoseResponseParentPanel().add(dRPanel, gridBagConstraints);
}

From source file:com.att.aro.ui.view.menu.datacollector.DeviceDialogOptions.java

private void loadRadioGroupCollector() {
    rooted = ResourceBundleHelper.getMessageString("dlog.collector.option.rooted");
    vpn = ResourceBundleHelper.getMessageString("dlog.collector.option.vpn");
    btnRooted = new JRadioButton(rooted);
    btnVpn = new JRadioButton(vpn);

    btnRooted.setActionCommand(rooted);/*from  w  w  w.j  av a  2s. co m*/
    btnVpn.setActionCommand(vpn);

    btnRooted.setMnemonic(KeyEvent.VK_R);
    btnVpn.setMnemonic(KeyEvent.VK_V);

    btnRooted.addActionListener(this);
    btnVpn.addActionListener(this);

    btnRooted.setEnabled(false);

    btnVpn.setSelected(true);

    // only group the rooted & vpn
    radioBtnVpnRoot = new ButtonGroup();
    radioBtnVpnRoot.add(btnRooted);
    radioBtnVpnRoot.add(btnVpn);
    btnRooted.setEnabled(true);
}

From source file:emailplugin.MailCreator.java

/**
 * Gives the User the opportunity to specify which Desktop he uses (KDE or
 * Gnome)//from  w  w  w.  j  a va2s  .  c o m
 *
 * @param parent
 *          Parent Dialog
 * @return true if KDE or Gnome has been selected, false if the User wanted to
 *         specify the App
 */
private boolean showKdeGnomeDialog(Frame parent) {
    final JDialog dialog = new JDialog(parent, true);

    dialog.setTitle(mLocalizer.msg("chooseTitle", "Choose"));

    JPanel panel = (JPanel) dialog.getContentPane();
    panel.setLayout(new FormLayout("10dlu, fill:pref:grow",
            "default, 3dlu, default, 3dlu, default, 3dlu, default, 3dlu:grow, default"));
    panel.setBorder(Borders.DIALOG_BORDER);

    CellConstraints cc = new CellConstraints();

    panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("cantConfigure", "Can't configure on your system")),
            cc.xyw(1, 1, 2));

    JRadioButton kdeButton = new JRadioButton(mLocalizer.msg("kde", "I am using KDE"));
    panel.add(kdeButton, cc.xy(2, 3));

    JRadioButton gnomeButton = new JRadioButton(mLocalizer.msg("gnome", "I am using Gnome"));
    panel.add(gnomeButton, cc.xy(2, 5));

    JRadioButton selfButton = new JRadioButton(mLocalizer.msg("self", "I want to configure by myself"));
    panel.add(selfButton, cc.xy(2, 7));

    ButtonGroup group = new ButtonGroup();
    group.add(kdeButton);
    group.add(gnomeButton);
    group.add(selfButton);

    selfButton.setSelected(true);

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
        }
    });

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.add(ok);
    panel.add(buttonPanel, cc.xy(2, 9));

    UiUtilities.registerForClosing(new WindowClosingIf() {
        public void close() {
            dialog.setVisible(false);
        }

        public JRootPane getRootPane() {
            return dialog.getRootPane();
        }
    });

    dialog.getRootPane().setDefaultButton(ok);

    dialog.pack();
    UiUtilities.centerAndShow(dialog);

    if (kdeButton.isSelected()) {
        mSettings.setApplication("kfmclient");
        mSettings.setParameter("exec {content}");
    } else if (gnomeButton.isSelected()) {
        mSettings.setApplication("gnome-open");
        mSettings.setParameter("{content}");
    } else {
        Plugin.getPluginManager().showSettings(mPlugin);
        return false;
    }

    return true;
}

From source file:DialogDemo.java

private JPanel createIconDialogBox() {
    JButton showItButton = null;//w ww  . ja v  a  2  s . co m

    final int numButtons = 6;
    JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();

    final String plainCommand = "plain";
    final String infoCommand = "info";
    final String questionCommand = "question";
    final String errorCommand = "error";
    final String warningCommand = "warning";
    final String customCommand = "custom";

    radioButtons[0] = new JRadioButton("Plain (no icon)");
    radioButtons[0].setActionCommand(plainCommand);

    radioButtons[1] = new JRadioButton("Information icon");
    radioButtons[1].setActionCommand(infoCommand);

    radioButtons[2] = new JRadioButton("Question icon");
    radioButtons[2].setActionCommand(questionCommand);

    radioButtons[3] = new JRadioButton("Error icon");
    radioButtons[3].setActionCommand(errorCommand);

    radioButtons[4] = new JRadioButton("Warning icon");
    radioButtons[4].setActionCommand(warningCommand);

    radioButtons[5] = new JRadioButton("Custom icon");
    radioButtons[5].setActionCommand(customCommand);

    for (int i = 0; i < numButtons; i++) {
        group.add(radioButtons[i]);
    }
    radioButtons[0].setSelected(true);

    showItButton = new JButton("Show it!");
    showItButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();

            // no icon
            if (command == plainCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "A plain message",
                        JOptionPane.PLAIN_MESSAGE);
                // information icon
            } else if (command == infoCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.",
                        "Inane informational dialog", JOptionPane.INFORMATION_MESSAGE);

                // XXX: It doesn't make sense to make a question with
                // XXX: only one button.
                // XXX: See "Yes/No (but not in those words)" for a better solution.
                // question icon
            } else if (command == questionCommand) {
                JOptionPane.showMessageDialog(frame,
                        "You shouldn't use a message dialog " + "(like this)\n" + "for a question, OK?",
                        "Inane question", JOptionPane.QUESTION_MESSAGE);
                // error icon
            } else if (command == errorCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane error",
                        JOptionPane.ERROR_MESSAGE);
                // warning icon
            } else if (command == warningCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane warning",
                        JOptionPane.WARNING_MESSAGE);
                // custom icon
            } else if (command == customCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane custom dialog",
                        JOptionPane.INFORMATION_MESSAGE, icon);
            }
        }
    });

    return create2ColPane(iconDesc + ":", radioButtons, showItButton);
}

From source file:edu.uci.ics.jung.samples.PerspectiveVertexImageShaperDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the zoom features.//from  ww w  . j a  v  a2  s .co  m
 * 
 */
@SuppressWarnings("serial")
public PerspectiveVertexImageShaperDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseMultigraph<Number, Number>();
    Number[] vertices = createVertices(11);

    // a Map for the labels
    Map<Number, String> map = new HashMap<Number, String>();
    for (int i = 0; i < vertices.length; i++) {
        map.put(vertices[i], iconNames[i % iconNames.length]);
    }

    // a Map for the Icons
    Map<Number, Icon> iconMap = new HashMap<Number, Icon>();
    for (int i = 0; i < vertices.length; i++) {
        String name = "/images/topic" + iconNames[i] + ".gif";
        try {
            Icon icon = new LayeredIcon(
                    new ImageIcon(PerspectiveVertexImageShaperDemo.class.getResource(name)).getImage());
            iconMap.put(vertices[i], icon);
        } catch (Exception ex) {
            System.err.println("You need slashdoticons.jar in your classpath to see the image " + name);
        }
    }

    createEdges(vertices);

    final VertexStringerImpl<Number> vertexStringerImpl = new VertexStringerImpl<Number>(map);

    final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>(
            new EllipseVertexShapeTransformer<Number>());

    FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph);
    layout.setMaxIterations(100);
    vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400));

    vv.setBackground(Color.decode("0xffffdd"));
    final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>();
    vertexImageShapeFunction.setIconMap(iconMap);
    vertexIconFunction.setIconMap(iconMap);
    vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);
    vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl);
    PickedState<Number> ps = vv.getPickedVertexState();
    ps.addItemListener(new PickWithIconListener(vertexIconFunction));

    vv.addPostRenderPaintable(new VisualizationServer.Paintable() {
        int x;
        int y;
        Font font;
        FontMetrics metrics;
        int swidth;
        int sheight;
        String str = "Thank You, slashdot.org, for the images!";

        public void paint(Graphics g) {
            Dimension d = vv.getSize();
            if (font == null) {
                font = new Font(g.getFont().getName(), Font.BOLD, 20);
                metrics = g.getFontMetrics(font);
                swidth = metrics.stringWidth(str);
                sheight = metrics.getMaxAscent() + metrics.getMaxDescent();
                x = (d.width - swidth) / 2;
                y = (int) (d.height - sheight * 1.5);
            }
            g.setFont(font);
            Color oldColor = g.getColor();
            g.setColor(Color.lightGray);
            g.drawString(str, x, y);
            g.setColor(oldColor);
        }

        public boolean useTransform() {
            return false;
        }
    });

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();

    vv.setGraphMouse(graphMouse);

    this.viewSupport = new PerspectiveImageLensSupport<Number, Number>(vv);
    this.layoutSupport = new PerspectiveLayoutTransformSupport<Number, Number>(vv);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 0.9f, vv.getCenter());
        }
    });
    final JSlider horizontalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(80, super.getPreferredSize().height);
        }
    };

    final JSlider verticalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width, 80);
        }
    };
    verticalSlider.setOrientation(JSlider.VERTICAL);
    final ChangeListener changeListener = new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            int vval = -verticalSlider.getValue();
            int hval = horizontalSlider.getValue();

            Dimension d = vv.getSize();
            PerspectiveTransform pt = null;
            pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval,
                    d.height + hval, -vval, d.height - hval,

                    0, 0, d.width, 0, d.width, d.height, 0, d.height);

            viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            vv.repaint();
        }
    };
    horizontalSlider.addChangeListener(changeListener);
    verticalSlider.addChangeListener(changeListener);

    JPanel perspectivePanel = new JPanel(new BorderLayout());
    JPanel perspectiveCenterPanel = new JPanel(new BorderLayout());
    perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls"));
    final JButton center = new JButton("Center");
    center.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            horizontalSlider.setValue(0);
            verticalSlider.setValue(0);
        }
    });

    final JCheckBox noText = new JCheckBox("No Text");
    noText.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            JCheckBox cb = (JCheckBox) e.getSource();
            vertexStringerImpl.setEnabled(!cb.isSelected());
            vv.repaint();
        }
    });
    JPanel centerPanel = new JPanel();
    centerPanel.add(noText);

    ButtonGroup radio = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    none.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            boolean selected = e.getStateChange() == ItemEvent.SELECTED;
            if (selected) {
                if (viewSupport != null) {
                    viewSupport.deactivate();
                }
                if (layoutSupport != null) {
                    layoutSupport.deactivate();
                }
            }
            center.setEnabled(!selected);
            horizontalSlider.setEnabled(!selected);
            verticalSlider.setEnabled(!selected);
        }
    });
    none.setSelected(true);

    JRadioButton hyperView = new JRadioButton("View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JRadioButton hyperModel = new JRadioButton("Layout");
    hyperModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            layoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    radio.add(none);
    radio.add(hyperView);
    radio.add(hyperModel);

    JMenuBar menubar = new JMenuBar();
    JMenu modeMenu = graphMouse.getModeMenu();
    menubar.add(modeMenu);

    panel.setCorner(menubar);

    JPanel scaleGrid = new JPanel(new GridLayout(2, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel controls = new JPanel(new BorderLayout());
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid, BorderLayout.WEST);

    JPanel lensPanel = new JPanel(new GridLayout(2, 0));
    lensPanel.add(none);
    lensPanel.add(hyperView);
    lensPanel.add(hyperModel);

    perspectivePanel.add(lensPanel, BorderLayout.WEST);
    perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH);
    perspectivePanel.add(verticalSlider, BorderLayout.EAST);
    perspectiveCenterPanel.add(center);
    perspectivePanel.add(perspectiveCenterPanel);
    controls.add(perspectivePanel, BorderLayout.EAST);

    controls.add(centerPanel);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java

private JPanel createMaskingPanel(JFreeChart chart) {
    JPanel wrap = new JPanel(new BorderLayout());

    JPanel maskingPanel = new JPanel(new GridLayout(1, 1));
    maskingPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    //Horizontal group
    JPanel managePanel = new JPanel(new BorderLayout());
    managePanel.setBorder(// ww  w . j a v  a 2  s . c  om
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Region of Interests"));

    JPanel inner = new JPanel(new LCBLayout(6));
    inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    inner.add(new JLabel("Select Region"));
    roiCombo = new JComboBox(panel.getMasks().toArray());
    //      colourScaleCombo.setMaximumRowCount(7);
    roiCombo.setActionCommand(CHANGE_ROI_COMMAND);
    roiCombo.addActionListener(this);
    roiCombo.setSelectedIndex(-1);
    inner.add(roiCombo);
    inner.add(new JLabel());

    inner.add(new JLabel("or create"));
    JPanel createNewPanel = new JPanel(new GridLayout(1, 2));
    newRectangleButton = new JButton("New Rectangle");
    newRectangleButton.setActionCommand(CREATE_NEW_RECT_REGION_COMMAND);
    newRectangleButton.addActionListener(this);
    newEllipseButton = new JButton("New Ellipse");
    newEllipseButton.setActionCommand(CREATE_NEW_ELLIPSE_REGION_COMMAND);
    newEllipseButton.addActionListener(this);
    createNewPanel.add(newRectangleButton);
    createNewPanel.add(newEllipseButton);
    inner.add(createNewPanel);
    inner.add(new JLabel());

    JPanel editPanel = new JPanel(new BorderLayout());
    editPanel
            .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Edit the Region"));

    JPanel editInner = new JPanel(new LCBLayout(6));
    editInner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    editInner.add(new JLabel("Name"));
    roiName = new JTextField(10);
    //      colourScaleCombo.setMaximumRowCount(7);
    roiName.setActionCommand(CHANGE_ROI_NAME_COMMAND);
    roiName.addActionListener(this);
    editInner.add(roiName);
    editInner.add(new JLabel());

    editInner.add(new JLabel("Usage"));
    ButtonGroup buttonGroup = new ButtonGroup();
    JPanel radioPanel = new JPanel(new GridLayout(1, 2));
    inclusiveRadio = new JRadioButton("inclusive");
    inclusiveRadio.setActionCommand(USE_INCLUSIVE_COMMAND);
    inclusiveRadio.addActionListener(this);
    buttonGroup.add(inclusiveRadio);
    radioPanel.add(inclusiveRadio);
    exclusiveRadio = new JRadioButton("exclusive");
    exclusiveRadio.setActionCommand(USE_EXCLUSIVE_COMMAND);
    exclusiveRadio.addActionListener(this);
    buttonGroup.add(exclusiveRadio);
    radioPanel.add(exclusiveRadio);
    editInner.add(radioPanel);
    editInner.add(new JLabel());

    editInner.add(new JLabel("Shape"));
    //      ButtonGroup shapeGroup = new ButtonGroup();
    //      JPanel shapePanel = new JPanel(new GridLayout(1, 2));
    //      rectangleRadio = new JRadioButton("rectangle");
    //      rectangleRadio.setActionCommand(CHOOSE_RECTANGLE_SHAPE_COMMAND);
    //      rectangleRadio.addActionListener(this);
    //      shapeGroup.add(rectangleRadio);
    //      shapePanel.add(rectangleRadio);
    //      ellipseRadio = new JRadioButton("ellipse");
    //      ellipseRadio.setActionCommand(CHOOSE_ELLIPSE_SHAPE_COMMAND);
    //      ellipseRadio.addActionListener(this);
    //      shapeGroup.add(ellipseRadio);
    //      shapePanel.add(ellipseRadio);
    //      editInner.add(shapePanel);
    shapeLabel = new JLabel();
    editInner.add(shapeLabel);
    editInner.add(new JLabel());

    editInner.add(new JLabel("X Range"));
    JPanel xRangePanel = new JPanel(new GridLayout(1, 2));
    JPanel xMinPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    xMinPanel.add(new JLabel("min: "));
    xMin = new JTextField(10);
    //      xMin.setActionCommand(CHANGE_XMIN_COMMAND);
    //      xMin.addActionListener(this);
    xMin.addKeyListener(this);
    xMinPanel.add(xMin);
    xRangePanel.add(xMinPanel);
    JPanel xMaxPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    xMaxPanel.add(new JLabel("max: "));
    xMax = new JTextField(10);
    //      xMax.setActionCommand(CHANGE_XMAX_COMMAND);
    xMax.addKeyListener(this);
    xMaxPanel.add(xMax);
    xRangePanel.add(xMaxPanel);
    editInner.add(xRangePanel);
    editInner.add(new JLabel());

    editInner.add(new JLabel("Y Range"));
    JPanel yRangePanel = new JPanel(new GridLayout(1, 2));
    JPanel yMinPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    yMinPanel.add(new JLabel("min: "));
    yMin = new JTextField(10);
    //      yMin.setActionCommand(CHANGE_YMIN_COMMAND);
    //      yMin.addActionListener(this);
    yMin.addKeyListener(this);
    yMinPanel.add(yMin);
    yRangePanel.add(yMinPanel);
    JPanel yMaxPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    yMaxPanel.add(new JLabel("max: "));
    yMax = new JTextField(10);
    //      yMax.setActionCommand(CHANGE_YMAX_COMMAND);
    //      yMax.addActionListener(this);
    yMax.addKeyListener(this);
    yMaxPanel.add(yMax);
    yRangePanel.add(yMaxPanel);
    editInner.add(yRangePanel);
    editInner.add(new JLabel());

    editInner.add(new JLabel());
    JPanel applyPanel = new JPanel(new GridLayout(1, 2));
    deleteButton = new JButton("Remove");
    deleteButton.setEnabled(false);
    deleteButton.setActionCommand(REMOVE_CHANGE_ACTION);
    deleteButton.addActionListener(this);
    applyPanel.add(deleteButton);
    applyPanel.add(new JLabel());
    applyButton = new JButton("Apply");
    applyButton.setEnabled(false);
    applyButton.setActionCommand(APPLY_CHANGE_ACTION);
    applyButton.addActionListener(this);
    applyPanel.add(applyButton);
    editInner.add(applyPanel);
    editInner.add(new JLabel());
    //      inner.add(new JLabel("X Range"));
    //      inner.add(inclusiveRadio);
    //      exclusiveRadio = new JRadioButton("exclusive");
    //      exclusiveRadio.setActionCommand(USE_EXCLUSIVE_COMMAND);
    //      exclusiveRadio.addActionListener(this);
    //      inner.add(exclusiveRadio);
    editPanel.add(editInner, BorderLayout.NORTH);
    managePanel.add(editPanel, BorderLayout.SOUTH);
    managePanel.add(inner, BorderLayout.NORTH);
    maskingPanel.add(managePanel);
    wrap.setName("ROI");

    wrap.add(maskingPanel, BorderLayout.NORTH);
    return wrap;
}