Example usage for javax.swing JRadioButton setActionCommand

List of usage examples for javax.swing JRadioButton setActionCommand

Introduction

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

Prototype

public void setActionCommand(String actionCommand) 

Source Link

Document

Sets the action command for this button.

Usage

From source file:de.interactive_instruments.ShapeChange.UI.DefaultDialog.java

private void addRadioButton(JPanel panel, ButtonGroup group, String label, String value, String parameter) {
    JRadioButton radioButton;
    panel.add(radioButton = new JRadioButton(label, parameter.equalsIgnoreCase(value)));
    radioButton.setActionCommand(value);
    group.add(radioButton);//from  ww  w . java2 s  .  c o m
}

From source file:FrameDemo2.java

protected JComponent createOptionControls() {
    JLabel label1 = new JLabel("Decoration options for subsequently created frames:");
    ButtonGroup bg1 = new ButtonGroup();
    JLabel label2 = new JLabel("Icon options:");
    ButtonGroup bg2 = new ButtonGroup();

    // Create the buttons
    JRadioButton rb1 = new JRadioButton();
    rb1.setText("Look and feel decorated");
    rb1.setActionCommand(LF_DECORATIONS);
    rb1.addActionListener(this);
    rb1.setSelected(true);/*from   w  w w  . jav  a  2s  . c o  m*/
    bg1.add(rb1);
    //
    JRadioButton rb2 = new JRadioButton();
    rb2.setText("Window system decorated");
    rb2.setActionCommand(WS_DECORATIONS);
    rb2.addActionListener(this);
    bg1.add(rb2);
    //
    JRadioButton rb3 = new JRadioButton();
    rb3.setText("No decorations");
    rb3.setActionCommand(NO_DECORATIONS);
    rb3.addActionListener(this);
    bg1.add(rb3);
    //
    //
    JRadioButton rb4 = new JRadioButton();
    rb4.setText("Default icon");
    rb4.setActionCommand(DEFAULT_ICON);
    rb4.addActionListener(this);
    rb4.setSelected(true);
    bg2.add(rb4);
    //
    JRadioButton rb5 = new JRadioButton();
    rb5.setText("Icon from a JPEG file");
    rb5.setActionCommand(FILE_ICON);
    rb5.addActionListener(this);
    bg2.add(rb5);
    //
    JRadioButton rb6 = new JRadioButton();
    rb6.setText("Painted icon");
    rb6.setActionCommand(PAINT_ICON);
    rb6.addActionListener(this);
    bg2.add(rb6);

    // Add everything to a container.
    Box box = Box.createVerticalBox();
    box.add(label1);
    box.add(Box.createVerticalStrut(5)); // spacer
    box.add(rb1);
    box.add(rb2);
    box.add(rb3);
    //
    box.add(Box.createVerticalStrut(15)); // spacer
    box.add(label2);
    box.add(Box.createVerticalStrut(5)); // spacer
    box.add(rb4);
    box.add(rb5);
    box.add(rb6);

    // Add some breathing room.
    box.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    return box;
}

From source file:com.emental.mindraider.ui.dialogs.AttachmentJDialog.java

/**
 * Concetructor./*  w ww .jav  a  2s  .com*/
 * 
 * @param noteResource
 *            The concept resource.
 * @param dragAndDropReference
 *            The drag'n'drop reference.
 */
public AttachmentJDialog(ConceptResource conceptResource, DragAndDropReference dragAndDropReference) {

    super(Messages.getString("AttachmentJDialog.title"));
    this.conceptResource = conceptResource;
    getContentPane().setLayout(new BorderLayout());
    JPanel p, pp;

    p = new JPanel();
    p.setLayout(new BorderLayout());
    JLabel intro = new JLabel("<html>&nbsp;&nbsp;" + Messages.getString("AttachmentJDialog.introduction")
            + "&nbsp;&nbsp;<br><br></html>");
    p.add(intro, BorderLayout.NORTH);
    p.add(new JLabel("<html>&nbsp;&nbsp;" + Messages.getString("AttachmentJDialog.description") + "</html>"),
            BorderLayout.CENTER);
    description = new JTextField(38);
    pp = new JPanel(new FlowLayout(FlowLayout.LEFT));
    pp.add(description);
    p.add(pp, BorderLayout.SOUTH);
    getContentPane().add(p, BorderLayout.NORTH);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.setBorder(new TitledBorder(Messages.getString("AttachmentJDialog.resource")));

    ButtonGroup attachType = new ButtonGroup();

    JPanel webPanel = new JPanel();
    webPanel.setLayout(new BorderLayout());
    webType = new JRadioButton(Messages.getString("AttachmentJDialog.web"));
    webType.setActionCommand(WEB);
    webType.addActionListener(this);
    webType.setSelected(true);
    attachType.add(webType);
    webPanel.add(webType, BorderLayout.NORTH);
    urlTextField = new JTextField("http://", 35);
    urlTextField.selectAll();
    urlTextField.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                attach();
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.LEFT));
    p.add(new JLabel("   "));
    p.add(urlTextField);
    webPanel.add(p, BorderLayout.SOUTH);
    mainPanel.add(webPanel, BorderLayout.NORTH);

    JPanel localPanel = new JPanel();
    localPanel.setLayout(new BorderLayout());
    JRadioButton localType = new JRadioButton(Messages.getString("AttachmentJDialog.local"));
    localType.setActionCommand(LOCAL);
    localType.addActionListener(this);
    localPanel.add(localType, BorderLayout.NORTH);
    pathTextField = new JTextField(35);
    pathTextField.setEnabled(false);
    browseButton = new JButton(Messages.getString("AttachmentJDialog.browse"));
    browseButton.setToolTipText(Messages.getString("AttachmentJDialog.browseTip"));
    browseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            fc.setApproveButtonText(Messages.getString("AttachmentJDialog.attach"));
            fc.setControlButtonsAreShown(true);
            fc.setDialogTitle(Messages.getString("AttachmentJDialog.chooseAttachment"));
            fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            int returnVal = fc.showOpenDialog(AttachmentJDialog.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                pathTextField.setText(file.toString());
            }
        }
    });
    browseButton.setEnabled(false);
    pp = new JPanel();
    pp.setLayout(new BorderLayout());
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.LEFT));
    p.add(new JLabel("   "));
    pp.add(p, BorderLayout.NORTH);
    p.add(pathTextField);
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p.add(browseButton);
    pp.add(p, BorderLayout.SOUTH);
    localPanel.add(pp, BorderLayout.SOUTH);
    attachType.add(localType);
    mainPanel.add(localPanel, BorderLayout.SOUTH);

    getContentPane().add(mainPanel, BorderLayout.CENTER);

    // buttons
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton addButton = new JButton(Messages.getString("AttachmentJDialog.attach"));

    p.add(addButton);
    addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            attach();
        }
    });
    JButton cancelButton = new JButton(Messages.getString("AttachmentJDialog.cancel"));
    p.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            AttachmentJDialog.this.dispose();
        }
    });
    getContentPane().add(p, BorderLayout.SOUTH);

    /*
     * drag and drop initialization
     */
    if (dragAndDropReference != null) {
        if (dragAndDropReference.getType() == DragAndDropReference.BROWSER_LINK) {
            urlTextField.setText(dragAndDropReference.getReference());
            localType.setSelected(false);
            webType.setSelected(true);
            enableWebTypeButtons();
        } else {
            pathTextField.setText(dragAndDropReference.getReference());
            localType.setSelected(true);
            webType.setSelected(false);
            enableLocalTypeButtons();
        }
        description.setText(dragAndDropReference.getTitle());
    }

    pack();
    Gfx.centerAndShowWindow(this);
}

From source file:net.pandoragames.far.ui.swing.RenameFilesPanel.java

private void init(SwingConfig config, ComponentRepository componentRepository) {

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    this.setBorder(
            BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING));

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    JLabel patternLabel = new JLabel(localizer.localize("label.find-pattern"));
    this.add(patternLabel);
    filenamePattern = new JTextField();
    filenamePattern.setPreferredSize(/*from   w ww . j av a 2  s .  co m*/
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    filenamePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    filenamePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory findUndoManager = new UndoHistory();
    findUndoManager.registerUndoHistory(filenamePattern);
    findUndoManager.registerSnapshotHistory(filenamePattern);
    componentRepository.getReplaceCommand().addResetable(findUndoManager);
    filenamePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setPatternString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(filenamePattern);
    this.add(filenamePattern);
    JCheckBox caseBox = new JCheckBox(localizer.localize("label.ignore-case"));
    caseBox.setSelected(true);
    caseBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setIgnoreCase((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseBox);
    JCheckBox regexBox = new JCheckBox(localizer.localize("label.regular-expression"));
    regexBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setRegexPattern((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(regexBox);
    JPanel extensionPanel = new JPanel();
    extensionPanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-extension")));
    extensionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    extensionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    extensionPanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 60));
    extensionPanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 100));
    ButtonGroup extensionGroup = new ButtonGroup();
    JRadioButton protectButton = new JRadioButton(localizer.localize("label.protect-extension"));
    protectButton.setSelected(true);
    protectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setProtectExtension(true);
            updateFileTable();
        }
    });
    extensionGroup.add(protectButton);
    extensionPanel.add(protectButton);
    JRadioButton includeButton = new JRadioButton(localizer.localize("label.include-extension"));
    includeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(false);
            dataModel.setProtectExtension(false);
            updateFileTable();
        }
    });
    extensionGroup.add(includeButton);
    extensionPanel.add(includeButton);
    JRadioButton onlyButton = new JRadioButton(localizer.localize("label.only-extension"));
    onlyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(true);
            updateFileTable();
        }
    });
    extensionGroup.add(onlyButton);
    extensionPanel.add(onlyButton);
    this.add(extensionPanel);

    this.add(Box.createVerticalGlue());
    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    // replace
    JLabel replaceLabel = new JLabel(localizer.localize("label.replacement-pattern"));
    this.add(replaceLabel);
    replacePattern = new JTextField();
    replacePattern.setPreferredSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    replacePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    replacePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory undoManager = new UndoHistory();
    undoManager.registerUndoHistory(replacePattern);
    undoManager.registerSnapshotHistory(replacePattern);
    componentRepository.getReplaceCommand().addResetable(undoManager);
    replacePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setReplacementString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(replacePattern);
    this.add(replacePattern);

    // treat case
    JPanel modifyCasePanel = new JPanel();
    modifyCasePanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-case")));
    modifyCasePanel.setLayout(new BoxLayout(modifyCasePanel, BoxLayout.Y_AXIS));
    modifyCasePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    modifyCasePanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 100));
    modifyCasePanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 200));
    ButtonGroup modifyCaseGroup = new ButtonGroup();
    ActionListener radioButtonListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand();
            dataModel.setTreatCase(RenameForm.CASEHANDLING.valueOf(cmd));
            updateFileTable();
        }
    };
    JRadioButton lowerButton = new JRadioButton(localizer.localize("label.to-lower-case"));
    lowerButton.setActionCommand(RenameForm.CASEHANDLING.LOWER.name());
    lowerButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(lowerButton);
    modifyCasePanel.add(lowerButton);
    JRadioButton upperButton = new JRadioButton(localizer.localize("label.to-upper-case"));
    upperButton.setActionCommand(RenameForm.CASEHANDLING.UPPER.name());
    upperButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(upperButton);
    modifyCasePanel.add(upperButton);
    JRadioButton keepButton = new JRadioButton(localizer.localize("label.preserve-case"));
    keepButton.setActionCommand(RenameForm.CASEHANDLING.PRESERVE.name());
    keepButton.setSelected(true);
    keepButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(keepButton);
    modifyCasePanel.add(keepButton);
    this.add(modifyCasePanel);

    // prevent case conflict
    JCheckBox caseConflictBox = new JCheckBox(localizer.localize("label.prevent-case-conflict"));
    caseConflictBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    caseConflictBox.setSelected(true);
    caseConflictBox.setEnabled(!SwingConfig.isWindows()); // disabled on windows
    caseConflictBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setPreventCaseConflict((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseConflictBox);

    this.add(Box.createVerticalGlue());

}

From source file:GenealogyExample.java

public GenealogyExample() {
    super(new BorderLayout());

    //Construct the panel with the toggle buttons.
    JRadioButton showDescendant = new JRadioButton("Show descendants", true);
    final JRadioButton showAncestor = new JRadioButton("Show ancestors");
    ButtonGroup bGroup = new ButtonGroup();
    bGroup.add(showDescendant);//ww  w .  j a v  a  2 s. c om
    bGroup.add(showAncestor);
    showDescendant.addActionListener(this);
    showAncestor.addActionListener(this);
    showAncestor.setActionCommand(SHOW_ANCESTOR_CMD);
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(showDescendant);
    buttonPanel.add(showAncestor);

    //Construct the tree.
    tree = new GenealogyTree(getGenealogyGraph());
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(200, 200));

    //Add everything to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(scrollPane, BorderLayout.CENTER);
}

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);//  w w w . j ava2s.co  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:GenealogyExample.java

public GenealogyExample() {
    super(new BorderLayout());

    // Construct the panel with the toggle buttons.
    JRadioButton showDescendant = new JRadioButton("Show descendants", true);
    final JRadioButton showAncestor = new JRadioButton("Show ancestors");
    ButtonGroup bGroup = new ButtonGroup();
    bGroup.add(showDescendant);//from w  w w .  j a  v  a  2 s  . co  m
    bGroup.add(showAncestor);
    showDescendant.addActionListener(this);
    showAncestor.addActionListener(this);
    showAncestor.setActionCommand(SHOW_ANCESTOR_CMD);
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(showDescendant);
    buttonPanel.add(showAncestor);

    // Construct the tree.
    tree = new GenealogyTree(getGenealogyGraph());
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(200, 200));

    // Add everything to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(scrollPane, BorderLayout.CENTER);
}

From source file:net.pandoragames.far.ui.swing.dialog.SettingsDialog.java

private void init() {
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
    this.setResizable(false);

    JPanel basePanel = new JPanel();
    basePanel.setLayout(new BoxLayout(basePanel, BoxLayout.Y_AXIS));
    basePanel.setBorder(//  w  ww  .jav  a2 s .  c  o m
            BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING));
    registerCloseWindowKeyListener(basePanel);

    // sink for error messages
    MessageLabel errorField = new MessageLabel();
    errorField.setMinimumSize(new Dimension(100, swingConfig.getStandardComponentHight()));
    errorField.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING));
    TwoComponentsPanel lineError = new TwoComponentsPanel(errorField,
            Box.createRigidArea(new Dimension(1, swingConfig.getStandardComponentHight())));
    lineError.setAlignmentX(Component.LEFT_ALIGNMENT);
    basePanel.add(lineError);

    // character set
    JLabel labelCharset = new JLabel(swingConfig.getLocalizer().localize("label.default-characterset"));
    labelCharset.setAlignmentX(Component.LEFT_ALIGNMENT);
    basePanel.add(labelCharset);

    JComboBox listCharset = new JComboBox(swingConfig.getCharsetList().toArray());
    listCharset.setAlignmentX(Component.LEFT_ALIGNMENT);
    listCharset.setSelectedItem(swingConfig.getDefaultCharset());
    listCharset.setEditable(true);
    listCharset.setMaximumSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight()));

    listCharset.addActionListener(new CharacterSetListener(errorField));
    listCharset.setEditor(new CharacterSetEditor(errorField));
    basePanel.add(listCharset);

    basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    // select the group selector
    JPanel selectorPanel = new JPanel();
    selectorPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    selectorPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    // linePattern.setAlignmentX( Component.LEFT_ALIGNMENT );
    JLabel labelSelector = new JLabel(swingConfig.getLocalizer().localize("label.group-ref-indicator"));
    selectorPanel.add(labelSelector);
    JComboBox selectorBox = new JComboBox(FARConfig.GROUPREFINDICATORLIST);
    selectorBox.setSelectedItem(Character.toString(groupReference));
    selectorBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            JComboBox cbox = (JComboBox) event.getSource();
            String indicator = (String) cbox.getSelectedItem();
            groupReference = indicator.charAt(0);
        }
    });
    selectorPanel.add(selectorBox);
    basePanel.add(selectorPanel);

    basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    // checkbox DO BACKUP
    JCheckBox doBackupFlag = new JCheckBox(swingConfig.getLocalizer().localize("label.create-backup"));
    doBackupFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    doBackupFlag.setHorizontalTextPosition(SwingConstants.LEADING);
    doBackupFlag.setSelected(replaceForm.isDoBackup());
    doBackupFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            doBackup = ItemEvent.SELECTED == event.getStateChange();
            backupFlagEvent = event;
        }
    });
    basePanel.add(doBackupFlag);

    JTextField backupDirPathTextField = new JTextField();
    backupDirPathTextField.setPreferredSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH, swingConfig.getStandardComponentHight()));
    backupDirPathTextField.setMaximumSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight()));
    backupDirPathTextField.setText(backupDirectory.getPath());
    backupDirPathTextField.setToolTipText(backupDirectory.getPath());
    backupDirPathTextField.setEditable(false);
    JButton openBaseDirFileChooserButton = new JButton(swingConfig.getLocalizer().localize("button.browse"));
    BrowseButtonListener backupDirButtonListener = new BrowseButtonListener(backupDirPathTextField,
            new BackUpDirectoryRepository(swingConfig, findForm, replaceForm, errorField),
            swingConfig.getLocalizer().localize("label.choose-backup-directory"));
    openBaseDirFileChooserButton.addActionListener(backupDirButtonListener);
    TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(backupDirPathTextField,
            openBaseDirFileChooserButton);
    lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT);
    basePanel.add(lineBaseDir);

    basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    JPanel fileInfoPanel = new JPanel();
    fileInfoPanel
            .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                    swingConfig.getLocalizer().localize("label.default-file-info")));
    fileInfoPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    fileInfoPanel.setLayout(new BoxLayout(fileInfoPanel, BoxLayout.Y_AXIS));
    JLabel fileInfoLabel = new JLabel(swingConfig.getLocalizer().localize("message.displayed-in-info-column"));
    fileInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    fileInfoPanel.add(fileInfoLabel);
    fileInfoPanel.add(Box.createHorizontalGlue());
    JRadioButton nothingRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.nothing"));
    nothingRadio.setAlignmentX(Component.LEFT_ALIGNMENT);
    nothingRadio.setActionCommand(SwingConfig.DefaultFileInfo.NOTHING.name());
    nothingRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.NOTHING);
    fileInfoOptions.add(nothingRadio);
    fileInfoPanel.add(nothingRadio);
    JRadioButton readOnlyRadio = new JRadioButton(
            swingConfig.getLocalizer().localize("label.read-only-warning"));
    readOnlyRadio.setAlignmentX(Component.LEFT_ALIGNMENT);
    readOnlyRadio.setActionCommand(SwingConfig.DefaultFileInfo.READONLY.name());
    readOnlyRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.READONLY);
    fileInfoOptions.add(readOnlyRadio);
    fileInfoPanel.add(readOnlyRadio);
    JRadioButton sizeRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.filesize"));
    sizeRadio.setAlignmentX(Component.LEFT_ALIGNMENT);
    sizeRadio.setActionCommand(SwingConfig.DefaultFileInfo.SIZE.name());
    sizeRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.SIZE);
    fileInfoOptions.add(sizeRadio);
    fileInfoPanel.add(sizeRadio);
    JCheckBox showPlainBytesFlag = new JCheckBox(
            "  " + swingConfig.getLocalizer().localize("label.show-plain-bytes"));
    showPlainBytesFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    showPlainBytesFlag.setHorizontalTextPosition(SwingConstants.LEADING);
    showPlainBytesFlag.setSelected(swingConfig.isShowPlainBytes());
    showPlainBytesFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            showBytes = ItemEvent.SELECTED == event.getStateChange();
        }
    });
    fileInfoPanel.add(showPlainBytesFlag);
    JRadioButton lastModifiedRadio = new JRadioButton(
            swingConfig.getLocalizer().localize("label.last-modified"));
    lastModifiedRadio.setAlignmentX(Component.LEFT_ALIGNMENT);
    lastModifiedRadio.setActionCommand(SwingConfig.DefaultFileInfo.LAST_MODIFIED.name());
    lastModifiedRadio
            .setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.LAST_MODIFIED);
    fileInfoOptions.add(lastModifiedRadio);
    fileInfoPanel.add(lastModifiedRadio);
    basePanel.add(fileInfoPanel);

    // buttons
    JPanel buttonPannel = new JPanel();
    buttonPannel.setAlignmentX(Component.LEFT_ALIGNMENT);
    buttonPannel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    // cancel
    JButton cancelButton = new JButton(swingConfig.getLocalizer().localize("button.cancel"));
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            SettingsDialog.this.dispose();
        }
    });
    buttonPannel.add(cancelButton);
    // save
    JButton saveButton = new JButton(swingConfig.getLocalizer().localize("button.save"));
    saveButton.addActionListener(new SaveButtonListener());
    buttonPannel.add(saveButton);
    this.getRootPane().setDefaultButton(saveButton);

    this.add(basePanel);
    this.add(buttonPannel);
    placeOnScreen(swingConfig.getScreenCenter());
}

From source file:edu.ucla.stat.SOCR.chart.SuperXYChart_QQ.java

public void initMapPanel() {
    listIndex = new int[dataTable.getColumnCount()];
    for (int j = 0; j < listIndex.length; j++)
        listIndex[j] = 1;/*from  w  w  w  .  j a v a  2s. co  m*/
    bPanel = new JPanel(new BorderLayout());
    mapPanel = new JPanel(new GridLayout(2, 3, 50, 50));
    bPanel.add(mapPanel, BorderLayout.CENTER);

    addButton1.addActionListener(this);
    addButton2.addActionListener(this);
    removeButton1.addActionListener(this);
    removeButton2.addActionListener(this);

    lModelAdded = new DefaultListModel();
    lModelDep = new DefaultListModel();
    lModelIndep = new DefaultListModel();

    int cellWidth = 10;

    listAdded = new JList(lModelAdded);
    listAdded.setSelectedIndex(0);
    listDepRemoved = new JList(lModelDep);
    listIndepRemoved = new JList(lModelIndep);

    paintMappingLists(listIndex);
    listAdded.setFixedCellWidth(cellWidth);
    listDepRemoved.setFixedCellWidth(cellWidth);
    listIndepRemoved.setFixedCellWidth(cellWidth);

    tools1 = new JToolBar(JToolBar.VERTICAL);
    tools2 = new JToolBar(JToolBar.VERTICAL);

    tools1.add(depLabel);
    //    tools2.add(indLabel);

    tools1.setFloatable(false);
    tools2.setFloatable(false);
    tools1.add(addButton1);
    tools1.add(removeButton1);
    //  tools2.add(addButton2);
    //   tools2.add(removeButton2);

    JRadioButton disChoices_normal;
    JRadioButton disChoices_poisson;

    //
    JPanel choicesPanel = new JPanel();
    disChoices_normal = new JRadioButton("Normal");
    disChoices_normal.addActionListener(this);
    disChoices_normal.setActionCommand(NORMAL);
    disChoices_normal.setSelected(true);
    disChoice = NORMAL;

    disChoices_poisson = new JRadioButton("Poisson");
    disChoices_poisson.addActionListener(this);
    disChoices_poisson.setActionCommand(POISSON);

    ButtonGroup group = new ButtonGroup();
    group.add(disChoices_normal);
    group.add(disChoices_poisson);
    choicesPanel.add(new JLabel("Choices of distribution:"));
    choicesPanel.add(disChoices_normal);
    choicesPanel.add(disChoices_poisson);
    choicesPanel.setPreferredSize(new Dimension(200, 100));

    mapPanel.add(new JScrollPane(listAdded));
    mapPanel.add(tools1);
    mapPanel.add(new JScrollPane(listDepRemoved));
    //      JPanel emptyPanel = new JPanel(new GridLayout(0,1));
    //   mapPanel.add(emptyPanel);
    mapPanel.add(choicesPanel);
    mapPanel.add(tools2);
    mapPanel.add(new JScrollPane(listIndepRemoved));

}

From source file:TexBug.java

JPanel texture2DPanel() {

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 0)); // horizontal

    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new GridLayout(0, 1)); // vertical
    panel.add(leftPanel);//from   w  ww  .  j av  a2  s .c om

    JPanel rightPanel = new JPanel();
    rightPanel.setLayout(new GridLayout(0, 1)); // vertical
    panel.add(rightPanel);

    texEnableCheckBox = new JCheckBox(texEnableString);

    // set up the action commands
    texEnableCheckBox.setActionCommand(texEnableString);

    // register the applet as the listener for the buttons
    texEnableCheckBox.addActionListener(this);

    // set the initial value
    texEnableCheckBox.setSelected(texEnable);

    // add the checkbox to the panel
    leftPanel.add(texEnableCheckBox);

    // texture boundary S
    leftPanel.add(new JLabel("Boundary S Mode:"));

    // create the buttons
    JRadioButton texBoundarySWrapButton = new JRadioButton(wrapString);
    JRadioButton texBoundarySClampButton = new JRadioButton(clampString);

    // set up the action commands
    texBoundarySWrapButton.setActionCommand(texBoundarySWrapString);
    texBoundarySClampButton.setActionCommand(texBoundarySClampString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup boundSButtonGroup = new ButtonGroup();
    boundSButtonGroup.add(texBoundarySWrapButton);
    boundSButtonGroup.add(texBoundarySClampButton);

    // register the applet as the listener for the buttons
    texBoundarySWrapButton.addActionListener(this);
    texBoundarySClampButton.addActionListener(this);

    // add the buttons to the panel
    leftPanel.add(texBoundarySWrapButton);
    leftPanel.add(texBoundarySClampButton);

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

    // texture boundary T
    leftPanel.add(new JLabel("Boundary T Mode:"));

    // create the buttons
    JRadioButton texBoundaryTWrapButton = new JRadioButton(wrapString);
    JRadioButton texBoundaryTClampButton = new JRadioButton(clampString);

    // set up the action commands
    texBoundaryTWrapButton.setActionCommand(texBoundaryTWrapString);
    texBoundaryTClampButton.setActionCommand(texBoundaryTClampString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup boundTButtonGroup = new ButtonGroup();
    boundTButtonGroup.add(texBoundaryTWrapButton);
    boundTButtonGroup.add(texBoundaryTClampButton);

    // register the applet as the listener for the buttons
    texBoundaryTWrapButton.addActionListener(this);
    texBoundaryTClampButton.addActionListener(this);

    // add the buttons to the panel
    leftPanel.add(texBoundaryTWrapButton);
    leftPanel.add(texBoundaryTClampButton);

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

    // texture min filter
    rightPanel.add(new JLabel("Min Filter:"));

    // create the buttons
    JRadioButton texMinFilterBasePointButton = new JRadioButton(texFilterBasePointString);
    JRadioButton texMinFilterBaseLinearButton = new JRadioButton(texFilterBaseLinearString);
    JRadioButton texMinFilterMultiPointButton = new JRadioButton(texFilterMultiPointString);
    JRadioButton texMinFilterMultiLinearButton = new JRadioButton(texFilterMultiLinearString);
    JRadioButton texMinFilterNicestButton = new JRadioButton(nicestString);
    JRadioButton texMinFilterFastestButton = new JRadioButton(fastestString);

    // set up the action commands
    texMinFilterBasePointButton.setActionCommand(texMinFilterBasePointString);
    texMinFilterBaseLinearButton.setActionCommand(texMinFilterBaseLinearString);
    texMinFilterMultiPointButton.setActionCommand(texMinFilterMultiPointString);
    texMinFilterMultiLinearButton.setActionCommand(texMinFilterMultiLinearString);
    texMinFilterNicestButton.setActionCommand(texMinFilterNicestString);
    texMinFilterFastestButton.setActionCommand(texMinFilterFastestString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup minFilterButtonGroup = new ButtonGroup();
    minFilterButtonGroup.add(texMinFilterBasePointButton);
    minFilterButtonGroup.add(texMinFilterBaseLinearButton);
    minFilterButtonGroup.add(texMinFilterMultiPointButton);
    minFilterButtonGroup.add(texMinFilterMultiLinearButton);
    minFilterButtonGroup.add(texMinFilterNicestButton);
    minFilterButtonGroup.add(texMinFilterFastestButton);

    // register the applet as the listener for the buttons
    texMinFilterBasePointButton.addActionListener(this);
    texMinFilterBaseLinearButton.addActionListener(this);
    texMinFilterMultiPointButton.addActionListener(this);
    texMinFilterMultiLinearButton.addActionListener(this);
    texMinFilterNicestButton.addActionListener(this);
    texMinFilterFastestButton.addActionListener(this);

    // add the buttons to the panel
    rightPanel.add(texMinFilterBasePointButton);
    rightPanel.add(texMinFilterBaseLinearButton);
    rightPanel.add(texMinFilterMultiPointButton);
    rightPanel.add(texMinFilterMultiLinearButton);
    rightPanel.add(texMinFilterNicestButton);
    rightPanel.add(texMinFilterFastestButton);

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

    // texture max filter
    rightPanel.add(new JLabel("Mag Filter:"));

    // create the buttons
    JRadioButton texMagFilterBasePointButton = new JRadioButton(texFilterBasePointString);
    JRadioButton texMagFilterBaseLinearButton = new JRadioButton(texFilterBaseLinearString);
    JRadioButton texMagFilterNicestButton = new JRadioButton(nicestString);
    JRadioButton texMagFilterFastestButton = new JRadioButton(fastestString);

    // set up the action commands
    texMagFilterBasePointButton.setActionCommand(texMagFilterBasePointString);
    texMagFilterBaseLinearButton.setActionCommand(texMagFilterBaseLinearString);
    texMagFilterNicestButton.setActionCommand(texMagFilterNicestString);
    texMagFilterFastestButton.setActionCommand(texMagFilterFastestString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup magFilterButtonGroup = new ButtonGroup();
    magFilterButtonGroup.add(texMagFilterBasePointButton);
    magFilterButtonGroup.add(texMagFilterBaseLinearButton);
    magFilterButtonGroup.add(texMagFilterNicestButton);
    magFilterButtonGroup.add(texMagFilterFastestButton);

    // register the applet as the listener for the buttons
    texMagFilterBasePointButton.addActionListener(this);
    texMagFilterBaseLinearButton.addActionListener(this);
    texMagFilterNicestButton.addActionListener(this);
    texMagFilterFastestButton.addActionListener(this);

    // add the buttons to the panel
    rightPanel.add(texMagFilterBasePointButton);
    rightPanel.add(texMagFilterBaseLinearButton);
    rightPanel.add(texMagFilterNicestButton);
    rightPanel.add(texMagFilterFastestButton);

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

    // MipMap Mode
    leftPanel.add(new JLabel("MipMap Mode:"));

    // create the buttons
    JRadioButton texMipMapBaseButton = new JRadioButton(texMipMapBaseString);
    JRadioButton texMipMapMultiButton = new JRadioButton(texMipMapMultiString);

    // set up the action commands
    texMipMapBaseButton.setActionCommand(texMipMapBaseString);
    texMipMapMultiButton.setActionCommand(texMipMapMultiString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup texMipMapButtonGroup = new ButtonGroup();
    texMipMapButtonGroup.add(texMipMapBaseButton);
    texMipMapButtonGroup.add(texMipMapMultiButton);

    // register the applet as the listener for the buttons
    texMipMapBaseButton.addActionListener(this);
    texMipMapMultiButton.addActionListener(this);

    // add the buttons to the panel
    leftPanel.add(texMipMapBaseButton);
    leftPanel.add(texMipMapMultiButton);

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

    return panel;

}