Example usage for javax.swing JButton setActionCommand

List of usage examples for javax.swing JButton setActionCommand

Introduction

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

Prototype

public void setActionCommand(String actionCommand) 

Source Link

Document

Sets the action command for this button.

Usage

From source file:org.jab.docsearch.DocSearch.java

private JToolBar createToolBar() {

    // tool bar/*from   w  w  w .j  av a  2s.  co  m*/
    JToolBar toolBar = new JToolBar();

    // file open
    JButton buttonOpen = new JButton(new ImageIcon(getClass().getResource("/icons/fileopen.png")));
    buttonOpen.setToolTipText(I18n.getString("tooltip.open"));
    buttonOpen.setActionCommand("ac_open");
    buttonOpen.addActionListener(this);
    buttonOpen.setMnemonic(KeyEvent.VK_O);
    buttonOpen.setEnabled(!env.isWebStart()); // disable in WebStart
    toolBar.add(buttonOpen);

    // file save
    JButton buttonSave = new JButton(new ImageIcon(getClass().getResource("/icons/filesave.png")));
    buttonSave.setToolTipText(I18n.getString("tooltip.save"));
    buttonSave.setActionCommand("ac_save");
    buttonSave.addActionListener(this);
    buttonSave.setMnemonic(KeyEvent.VK_S);
    buttonSave.setEnabled(!env.isWebStart()); // disable in WebStart
    toolBar.add(buttonSave);
    toolBar.addSeparator();

    // open browser
    JButton buttonBrowser = new JButton(new ImageIcon(getClass().getResource("/icons/html.png")));
    buttonBrowser.setToolTipText(I18n.getString("tooltip.open_in_browser"));
    buttonBrowser.setActionCommand("ac_openinbrowser");
    buttonBrowser.addActionListener(this);
    buttonBrowser.setMnemonic(KeyEvent.VK_E);
    buttonBrowser.setEnabled(!env.isWebStart()); // disable in WebStart
    toolBar.add(buttonBrowser);
    toolBar.addSeparator();

    // home
    JButton buttonHome = new JButton(new ImageIcon(getClass().getResource("/icons/home.png")));
    buttonHome.setToolTipText(I18n.getString("tooltip.home"));
    buttonHome.setActionCommand("ac_home");
    buttonHome.addActionListener(this);
    buttonHome.setMnemonic(KeyEvent.VK_H);
    toolBar.add(buttonHome);

    // refresh
    JButton buttonRefresh = new JButton(new ImageIcon(getClass().getResource("/icons/refresh.png")));
    buttonRefresh.setToolTipText(I18n.getString("tooltip.refresh"));
    buttonRefresh.setActionCommand("ac_refresh");
    buttonRefresh.addActionListener(this);
    buttonRefresh.setMnemonic(KeyEvent.VK_L);
    toolBar.add(buttonRefresh);
    toolBar.addSeparator();

    // result
    JButton buttonResult = new JButton(new ImageIcon(getClass().getResource("/icons/search_results.png")));
    buttonResult.setToolTipText(I18n.getString("tooltip.results"));
    buttonResult.setActionCommand("ac_result");
    buttonResult.addActionListener(this);
    buttonResult.setMnemonic(KeyEvent.VK_R);
    toolBar.add(buttonResult);
    toolBar.addSeparator();

    // bookmark
    JButton buttonBookMark = new JButton(new ImageIcon(getClass().getResource("/icons/bookmark.png")));
    buttonBookMark.setToolTipText(I18n.getString("tooltip.add_bookmark"));
    buttonBookMark.setActionCommand("ac_addbookmark");
    buttonBookMark.addActionListener(this);
    buttonBookMark.setMnemonic(KeyEvent.VK_M);
    toolBar.add(buttonBookMark);
    toolBar.addSeparator();

    // print
    JButton buttonPrint = new JButton(new ImageIcon(getClass().getResource("/icons/fileprint.png")));
    buttonPrint.setToolTipText(I18n.getString("tooltip.print"));
    buttonPrint.setActionCommand("ac_print");
    buttonPrint.addActionListener(this);
    buttonPrint.setMnemonic(KeyEvent.VK_P);
    toolBar.add(buttonPrint);
    toolBar.addSeparator();

    // setting
    JButton buttonSetting = new JButton(new ImageIcon(getClass().getResource("/icons/configure.png")));
    buttonSetting.setToolTipText(I18n.getString("tooltip.settings"));
    buttonSetting.setActionCommand("ac_settings");
    buttonSetting.addActionListener(this);
    buttonSetting.setMnemonic(KeyEvent.VK_HOME);
    toolBar.add(buttonSetting);
    toolBar.addSeparator();

    // stop
    buttonStop = new JButton(new ImageIcon(getClass().getResource("/icons/stop.png")));
    buttonStop.setToolTipText(I18n.getString("tooltip.stop"));
    buttonStop.setActionCommand("ac_stop");
    buttonStop.addActionListener(this);
    buttonStop.setMnemonic(KeyEvent.VK_X);
    toolBar.add(buttonStop);
    toolBar.addSeparator();

    //
    toolBar.setFloatable(false);

    // finished
    return toolBar;
}

From source file:org.jets3t.gui.ItemPropertiesDialog.java

/**
 * Initialise the GUI elements to display the given item.
 *
 * @param s3Item//from   w  ww  .j  av a2  s  . c  om
 * the S3Bucket or an S3Object whose details will be displayed
 */
private void initGui(boolean isObjectBased) {
    // Initialise skins factory.
    skinsFactory = SkinsFactory.getInstance(applicationProperties);

    // Set Skinned Look and Feel.
    LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel");
    try {
        UIManager.setLookAndFeel(lookAndFeel);
    } catch (UnsupportedLookAndFeelException e) {
        log.error("Unable to set skinned LookAndFeel", e);
    }

    this.setResizable(true);
    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    JPanel commonPropertiesContainer = skinsFactory.createSkinnedJPanel("ItemPropertiesCommonPanel");
    commonPropertiesContainer.setLayout(new GridBagLayout());
    JPanel metadataContainer = skinsFactory.createSkinnedJPanel("ItemPropertiesMetadataPanel");
    metadataContainer.setLayout(new GridBagLayout());
    JPanel grantsContainer = skinsFactory.createSkinnedJPanel("ItemPropertiesGrantsPanel");
    grantsContainer.setLayout(new GridBagLayout());

    if (!isObjectBased) {
        // Display bucket details.
        JLabel bucketNameLabel = skinsFactory.createSkinnedJHtmlLabel("BucketNameLabel");
        bucketNameLabel.setText("Bucket name:");
        bucketNameTextField = skinsFactory.createSkinnedJTextField("BucketNameTextField");
        bucketNameTextField.setEditable(false);
        JLabel bucketLocationLabel = skinsFactory.createSkinnedJHtmlLabel("BucketLocationLabel");
        bucketLocationLabel.setText("Location:");
        bucketLocationTextField = skinsFactory.createSkinnedJTextField("BucketLocationTextField");
        bucketLocationTextField.setEditable(false);
        JLabel bucketCreationDateLabel = skinsFactory.createSkinnedJHtmlLabel("BucketCreationDateLabel");
        bucketCreationDateLabel.setText("Creation date:");
        bucketCreationDateTextField = skinsFactory.createSkinnedJTextField("BucketCreationDateTextField");
        bucketCreationDateTextField.setEditable(false);
        ownerNameLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerNameLabel");
        ownerNameLabel.setText("Owner name:");
        ownerNameTextField = skinsFactory.createSkinnedJTextField("OwnerNameTextField");
        ownerNameTextField.setEditable(false);
        ownerIdLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerIdLabel");
        ownerIdLabel.setText("Owner ID:");
        ownerIdTextField = skinsFactory.createSkinnedJTextField("OwnerIdTextField");
        ownerIdTextField.setEditable(false);

        bucketIsRequesterPaysLabel = skinsFactory.createSkinnedJHtmlLabel("BucketIsRequesterPaysLabel");
        bucketIsRequesterPaysLabel.setText("Requester Pays?");
        bucketIsRequesterPaysCheckBox = skinsFactory.createSkinnedJCheckBox("BucketIsRequesterPaysCheckBox");
        bucketIsRequesterPaysCheckBox.setEnabled(false);

        int row = 0;
        commonPropertiesContainer.add(bucketNameLabel, new GridBagConstraints(0, row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(bucketNameTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(bucketLocationLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(bucketLocationTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(bucketCreationDateLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(bucketCreationDateTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(bucketIsRequesterPaysLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(bucketIsRequesterPaysCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0,
                GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0));

        commonPropertiesContainer.add(ownerNameLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(ownerNameTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(ownerIdLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(ownerIdTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    } else {
        // Display object details.
        JLabel objectKeyLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectKeyLabel");
        objectKeyLabel.setText("Object key:");
        objectKeyTextField = skinsFactory.createSkinnedJTextField("ObjectKeyTextField");
        objectKeyTextField.setEditable(false);
        JLabel objectContentTypeLabel = skinsFactory.createSkinnedJHtmlLabel("ContentTypeLabel");
        objectContentTypeLabel.setText("Content type:");
        objectContentTypeTextField = skinsFactory.createSkinnedJTextField("ContentTypeTextField");
        objectContentTypeTextField.setEditable(false);
        JLabel objectContentLengthLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectContentLengthLabel");
        objectContentLengthLabel.setText("Size:");
        objectContentLengthTextField = skinsFactory.createSkinnedJTextField("ObjectContentLengthTextField");
        objectContentLengthTextField.setEditable(false);
        JLabel objectLastModifiedLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectLastModifiedLabel");
        objectLastModifiedLabel.setText("Last modified:");
        objectLastModifiedTextField = skinsFactory.createSkinnedJTextField("ObjectLastModifiedTextField");
        objectLastModifiedTextField.setEditable(false);
        JLabel objectETagLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectETagLabel");
        objectETagLabel.setText("ETag:");
        objectETagTextField = skinsFactory.createSkinnedJTextField("ObjectETagTextField");
        objectETagTextField.setEditable(false);
        JLabel bucketNameLabel = skinsFactory.createSkinnedJHtmlLabel("BucketNameLabel");
        bucketNameLabel.setText("Bucket name:");
        bucketNameTextField = skinsFactory.createSkinnedJTextField("BucketNameTextField");
        bucketNameTextField.setEditable(false);
        ownerNameLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerNameLabel");
        ownerNameLabel.setText("Owner name:");
        ownerNameTextField = skinsFactory.createSkinnedJTextField("OwnerNameTextField");
        ownerNameTextField.setEditable(false);
        ownerIdLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerIdLabel");
        ownerIdLabel.setText("Owner ID:");
        ownerIdTextField = skinsFactory.createSkinnedJTextField("OwnerIdTextField");
        ownerIdTextField.setEditable(false);

        commonPropertiesContainer.add(objectKeyLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(objectKeyTextField, new GridBagConstraints(1, 0, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(objectContentTypeLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(objectContentTypeTextField, new GridBagConstraints(1, 1, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(objectContentLengthLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(objectContentLengthTextField, new GridBagConstraints(1, 2, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(objectLastModifiedLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(objectLastModifiedTextField, new GridBagConstraints(1, 3, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(objectETagLabel, new GridBagConstraints(0, 4, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(objectETagTextField, new GridBagConstraints(1, 4, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(bucketNameLabel, new GridBagConstraints(0, 5, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(bucketNameTextField, new GridBagConstraints(1, 5, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(ownerNameLabel, new GridBagConstraints(0, 7, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(ownerNameTextField, new GridBagConstraints(1, 7, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        commonPropertiesContainer.add(ownerIdLabel, new GridBagConstraints(0, 8, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
        commonPropertiesContainer.add(ownerIdTextField, new GridBagConstraints(1, 8, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

        // Build metadata table.
        objectMetadataTableModel = new DefaultTableModel(new Object[] { "Name", "Value" }, 0) {
            private static final long serialVersionUID = -3762866886166776851L;

            @Override
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        TableSorter metadataTableSorter = new TableSorter(objectMetadataTableModel);
        JTable metadataTable = skinsFactory.createSkinnedJTable("MetadataTable");
        metadataTable.setModel(metadataTableSorter);
        metadataTableSorter.setTableHeader(metadataTable.getTableHeader());
        metadataContainer.add(new JScrollPane(metadataTable), new GridBagConstraints(0, 0, 1, 1, 1, 1,
                GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0));
    }

    // Build grants table.
    grantsTableModel = new DefaultTableModel(new Object[] { "Grantee", "Permission" }, 0) {
        private static final long serialVersionUID = -5882427163845726770L;

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    TableSorter grantsTableSorter = new TableSorter(grantsTableModel);
    grantsTable = skinsFactory.createSkinnedJTable("GrantsTable");
    grantsTable.setModel(grantsTableSorter);
    grantsTableSorter.setTableHeader(grantsTable.getTableHeader());
    grantsContainer.add(new JScrollPane(grantsTable), new GridBagConstraints(0, 0, 1, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0));

    // OK Button.
    JButton okButton = skinsFactory.createSkinnedJButton("ItemPropertiesOKButton");
    okButton.setText("Finished");
    okButton.setActionCommand("OK");
    okButton.addActionListener(this);

    // Set default ENTER button.
    this.getRootPane().setDefaultButton(okButton);

    // Put it all together.
    int row = 0;
    JPanel container = skinsFactory.createSkinnedJPanel("ItemPropertiesPanel");
    container.setLayout(new GridBagLayout());
    container.add(commonPropertiesContainer, new GridBagConstraints(0, row++, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    if (isObjectBased) {

        if (includeMetadata) {
            JHtmlLabel metadataLabel = skinsFactory.createSkinnedJHtmlLabel("MetadataLabel");
            metadataLabel.setText("<html><b>Metadata</b></html>");
            metadataLabel.setHorizontalAlignment(JLabel.CENTER);
            container.add(metadataLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, insetsVerticalSpace, 0, 0));
            container.add(metadataContainer, new GridBagConstraints(0, row++, 1, 1, 1, 1,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0));
        }

        // Object previous and next buttons, if we have multiple objects.
        previousObjectButton = skinsFactory.createSkinnedJButton("ItemPropertiesPreviousButton");
        previousObjectButton.setText("Previous");
        previousObjectButton.addActionListener(this);
        previousObjectButton.setEnabled(false);
        nextObjectButton = skinsFactory.createSkinnedJButton("ItemPropertiesNextButton");
        nextObjectButton.setText("Next");
        nextObjectButton.addActionListener(this);
        nextObjectButton.setEnabled(false);
        currentObjectLabel = skinsFactory.createSkinnedJHtmlLabel("ItemPropertiesCurrentObjectLabel");
        currentObjectLabel.setHorizontalAlignment(JLabel.CENTER);

        nextPreviousPanel = skinsFactory.createSkinnedJPanel("ItemPropertiesNextPreviousPanel");
        nextPreviousPanel.setLayout(new GridBagLayout());
        nextPreviousPanel.add(previousObjectButton, new GridBagConstraints(0, 0, 1, 1, 0, 0,
                GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0));
        nextPreviousPanel.add(currentObjectLabel, new GridBagConstraints(1, 0, 1, 1, 1, 0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
        nextPreviousPanel.add(nextObjectButton, new GridBagConstraints(2, 0, 1, 1, 0, 0,
                GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0));

        container.add(nextPreviousPanel, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.CENTER,
                GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
        row++;
    } else {
        JHtmlLabel grantsLabel = skinsFactory.createSkinnedJHtmlLabel("GrantsLabel");
        grantsLabel.setText("<html><b>Permissions</b></html>");
        grantsLabel.setHorizontalAlignment(JLabel.CENTER);
        container.add(grantsLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER,
                GridBagConstraints.HORIZONTAL, insetsVerticalSpace, 0, 0));
        container.add(grantsContainer, new GridBagConstraints(0, row++, 1, 1, 1, 1, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, insetsZero, 0, 0));
    }
    container.add(okButton, new GridBagConstraints(0, row++, 3, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    this.getContentPane().add(container);

    this.pack();
    if (isObjectBased) {
        this.setSize(400, (includeMetadata ? 550 : 400));
    }
    this.setLocationRelativeTo(this.getOwner());
}

From source file:org.kevinferrare.meijiChokoSolver.gui.SolverPanel.java

/**
 * Creates the controls inside the right bar
 * @return// w w  w . j a  v a  2 s . c  o  m
 */
private JPanel createControls() {
    ColumnJPanel panel = new ColumnJPanel();

    solverGUIOperatingModeJComboBox.addActionListener(this);
    solverGUIOperatingModeJComboBox.setActionCommand("solverGUIOperatingModeChanged");
    panel.add(solverGUIOperatingModeJComboBox);

    nextButton.addActionListener(this);
    nextButton.setActionCommand("next");
    panel.add(nextButton);

    JButton restartButton = new JButton("Restart");
    restartButton.setActionCommand("restartSolver");
    restartButton.addActionListener(this);
    panel.add(restartButton);

    JButton changePaletteButton = new JButton("Change colors");
    changePaletteButton.setActionCommand("changeColors");
    changePaletteButton.addActionListener(this);
    panel.add(changePaletteButton);

    return panel;
}

From source file:org.languagetool.gui.ConfigurationDialog.java

public boolean show(List<Rule> rules) {
    configChanged = false;//from w  w  w  . j  a  v a 2 s. com
    if (original != null) {
        config.restoreState(original);
    }
    dialog = new JDialog(owner, true);
    dialog.setTitle(messages.getString("guiConfigWindowTitle"));
    // close dialog when user presses Escape key:
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    ActionListener actionListener = new ActionListener() {
        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent actionEvent) {
            dialog.setVisible(false);
        }
    };
    JRootPane rootPane = dialog.getRootPane();
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    configurableRules.clear();

    Language lang = config.getLanguage();
    if (lang == null) {
        lang = Languages.getLanguageForLocale(Locale.getDefault());
    }

    String specialTabNames[] = config.getSpecialTabNames();
    int numConfigTrees = 2 + specialTabNames.length;
    configTree = new JTree[numConfigTrees];
    JPanel checkBoxPanel[] = new JPanel[numConfigTrees];
    DefaultMutableTreeNode rootNode;
    GridBagConstraints cons;

    for (int i = 0; i < numConfigTrees; i++) {
        checkBoxPanel[i] = new JPanel();
        cons = new GridBagConstraints();
        checkBoxPanel[i].setLayout(new GridBagLayout());
        cons.anchor = GridBagConstraints.NORTHWEST;
        cons.gridx = 0;
        cons.weightx = 1.0;
        cons.weighty = 1.0;
        cons.fill = GridBagConstraints.HORIZONTAL;
        Collections.sort(rules, new CategoryComparator());
        if (i == 0) {
            rootNode = createTree(rules, false, null); //  grammar options
        } else if (i == 1) {
            rootNode = createTree(rules, true, null); //  Style options
        } else {
            rootNode = createTree(rules, true, specialTabNames[i - 2]); //  Special tab options
        }
        configTree[i] = new JTree(getTreeModel(rootNode));

        configTree[i].applyComponentOrientation(ComponentOrientation.getOrientation(lang.getLocale()));

        configTree[i].setRootVisible(false);
        configTree[i].setEditable(false);
        configTree[i].setCellRenderer(new CheckBoxTreeCellRenderer());
        TreeListener.install(configTree[i]);
        checkBoxPanel[i].add(configTree[i], cons);
        configTree[i].addMouseListener(getMouseAdapter());
    }

    JPanel portPanel = new JPanel();
    portPanel.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.anchor = GridBagConstraints.WEST;
    cons.fill = GridBagConstraints.NONE;
    cons.weightx = 0.0f;
    if (!insideOffice) {
        createNonOfficeElements(cons, portPanel);
    } else {
        createOfficeElements(cons, portPanel);
    }

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    JButton okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton")));
    okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton")));
    okButton.setActionCommand(ACTION_COMMAND_OK);
    okButton.addActionListener(this);
    JButton cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton")));
    cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton")));
    cancelButton.setActionCommand(ACTION_COMMAND_CANCEL);
    cancelButton.addActionListener(this);
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    buttonPanel.add(okButton, cons);
    buttonPanel.add(cancelButton, cons);

    JTabbedPane tabpane = new JTabbedPane();

    JPanel jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);

    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.NORTHWEST;
    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getMotherTonguePanel(cons), cons);

    if (insideOffice) {
        cons.gridy += 3;
    } else {
        cons.gridy++;
    }
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getNgramPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getWord2VecPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(portPanel, cons);
    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.anchor = GridBagConstraints.WEST;
    for (JPanel extra : extraPanels) {
        //in case it wasn't in a containment hierarchy when user changed L&F
        SwingUtilities.updateComponentTreeUI(extra);
        cons.gridy++;
        jPane.add(extra, cons);
    }

    cons.gridy++;
    cons.fill = GridBagConstraints.BOTH;
    cons.weighty = 1.0f;
    jPane.add(new JPanel(), cons);

    tabpane.addTab(messages.getString("guiGeneral"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[0]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(0), cons);

    tabpane.addTab(messages.getString("guiGrammarRules"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[1]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(1), cons);

    cons.gridx = 0;
    cons.gridy++;
    cons.weightx = 5.0f;
    cons.weighty = 5.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(new JScrollPane(getSpecialRuleValuePanel()), cons);

    tabpane.addTab(messages.getString("guiStyleRules"), jPane);

    for (int i = 0; i < specialTabNames.length; i++) {
        jPane = new JPanel();
        jPane.setLayout(new GridBagLayout());
        cons = new GridBagConstraints();
        cons.insets = new Insets(4, 4, 4, 4);
        cons.gridx = 0;
        cons.gridy = 0;
        cons.weightx = 10.0f;
        cons.weighty = 10.0f;
        cons.fill = GridBagConstraints.BOTH;
        jPane.add(new JScrollPane(checkBoxPanel[i + 2]), cons);
        cons.weightx = 0.0f;
        cons.weighty = 0.0f;

        cons.gridx = 0;
        cons.gridy++;
        cons.fill = GridBagConstraints.NONE;
        cons.anchor = GridBagConstraints.LINE_END;
        jPane.add(getTreeButtonPanel(i + 2), cons);

        tabpane.addTab(specialTabNames[i], jPane);
    }

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    if (insideOffice) {
        JLabel versionText = new JLabel(messages.getString("guiUColorHint"));
        versionText.setForeground(Color.blue);
        jPane.add(versionText, cons);
        cons.gridy++;
    }

    cons.weightx = 2.0f;
    cons.weighty = 2.0f;
    cons.fill = GridBagConstraints.BOTH;

    jPane.add(new JScrollPane(getUnderlineColorPanel(rules)), cons);

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.NORTHWEST;
    contentPane.add(tabpane, cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.EAST;
    contentPane.add(buttonPanel, cons);

    dialog.pack();
    // center on screen:
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = dialog.getSize();
    dialog.setLocation(screenSize.width / 2 - frameSize.width / 2,
            screenSize.height / 2 - frameSize.height / 2);
    dialog.setLocationByPlatform(true);
    //  add Color tab after dimension was set
    tabpane.addTab(messages.getString("guiUnderlineColor"), jPane);

    for (JPanel extra : this.extraPanels) {
        if (extra instanceof SavablePanel) {
            ((SavablePanel) extra).componentShowing();
        }
    }
    dialog.setVisible(true);
    return configChanged;
}

From source file:org.lnicholls.galleon.apps.iTunes.iTunesOptionsPanel.java

public iTunesOptionsPanel(AppConfiguration appConfiguration) {

    super(appConfiguration);

    setLayout(new GridLayout(0, 1));

    iTunesConfiguration iTunesConfiguration = (iTunesConfiguration) appConfiguration;

    mTitleField = new JTextField(iTunesConfiguration.getName());

    mSharedField = new JCheckBox("Share");

    mSharedField.setSelected(iTunesConfiguration.isShared());

    mSharedField.setToolTipText("Share this app");

    String playlistPath = iTunesConfiguration.getPlaylistPath();

    if (playlistPath == null) {

        if (SystemUtils.IS_OS_MAC_OSX)

            playlistPath = "/Users/" + System.getProperty("user.name")
                    + "/Music/iTunes/iTunes Music Library.xml";

        else/*from www .  j a v a  2  s . c  om*/

            playlistPath = "C:\\Documents and Settings\\" + System.getProperty("user.name")

                    + "\\My Documents\\My Music\\iTunes\\iTunes Music Library.xml";

    }

    mPlaylistPathField = new JTextField(playlistPath);

    FormLayout layout = new FormLayout("right:pref, 3dlu, 50dlu:g, 3dlu, pref, right:pref:grow", "pref, " + // general

            "9dlu, " + "pref, " + // title

            "3dlu, " + "pref, " + // share

            "3dlu, " + "pref, " // username

    );

    PanelBuilder builder = new PanelBuilder(layout);

    //DefaultFormBuilder builder = new DefaultFormBuilder(new FormDebugPanel(), layout);

    builder.setDefaultDialogBorder();

    CellConstraints cc = new CellConstraints();

    builder.addSeparator("General", cc.xyw(1, 1, 4));

    builder.addLabel("Title", cc.xy(1, 3));

    builder.add(mTitleField, cc.xyw(3, 3, 1));

    builder.add(mSharedField, cc.xyw(3, 5, 1));

    builder.addLabel("Playlist Path", cc.xy(1, 7));

    builder.add(mPlaylistPathField, cc.xyw(3, 7, 1));

    JButton button = new JButton("...");

    button.setActionCommand("pick");

    button.addActionListener(this);

    builder.add(button, cc.xyw(5, 7, 1));

    JPanel panel = builder.getPanel();

    //FormDebugUtils.dumpAll(panel);

    add(panel);

}

From source file:org.mc.okapi.Correlation.java

/**
 * Create the dialog./*from   w  ww .j  a  v  a 2  s  .  c o m*/
 */
public Correlation() {

    setTitle("Correlation");
    setIconImage(Toolkit.getDefaultToolkit().getImage("src/images/ico/extra/science_32.png"));
    setBounds(100, 100, 450, 140);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(null);

    JLabel lblIx = new JLabel("X:");
    lblIx.setBounds(110, 11, 46, 14);
    contentPanel.add(lblIx);

    JLabel lblIy = new JLabel("Y:");
    lblIy.setBounds(286, 11, 46, 14);
    contentPanel.add(lblIy);

    JLabel lblX = new JLabel("X Label:");
    lblX.setBounds(83, 44, 88, 14);
    contentPanel.add(lblX);

    tfX = new JTextField();
    tfX.setBounds(128, 41, 104, 23);
    contentPanel.add(tfX);
    tfX.setColumns(10);

    JLabel lblY = new JLabel("Y Label:");
    lblY.setBounds(260, 44, 82, 14);
    contentPanel.add(lblY);

    tfY = new JTextField();
    tfY.setBounds(307, 41, 104, 23);
    contentPanel.add(tfY);
    tfY.setColumns(10);
    {
        JButton okButton = new JButton("OK");
        okButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

                double[] X = new double[data.getRowCount()];
                double[] Y = new double[data.getRowCount()];

                for (int i = 0; i < X.length; i++) {
                    X[i] = Double.valueOf(datmat.getColumnElements(cbX.getSelectedIndex())[i]);
                }

                for (int i = 0; i < Y.length; i++) {
                    Y[i] = Double.valueOf(datmat.getColumnElements(cbY.getSelectedIndex())[i]);
                }

                Plot plotxy = new Plot(X, Y, tfX.getText(), tfY.getText(),
                        "(" + tfX.getText() + "," + tfY.getText() + ")", "Correlation",
                        "r=" + new PearsonsCorrelation().correlation(X, Y));
                plotxy.pack();
                plotxy.setVisible(true);

                //System.out.println(Arrays.toString(datmat.getColumnElements(1)));

                //Runtime.getRuntime().exec("CMD /C start R CMD BATCH --no-save --no-restore --slave -f src/r/cor.R \"--args inFile='"+inFile+"' outFile='"+outPath+"/"+tfoutfile.getText()+"' iX='"+tfiX.getText()+"' iY='"+tfiY.getText()+"'\" ");
                //Runtime.getRuntime().exec("CMD /C start Rscript cor.R '"+inFile+"' '"+outPath+"/"+tfoutfile.getText()+"' "+tfiX.getText()+" "+tfiY.getText());
                //Rsession ss = Rsession.newInstanceTry(System.out,null);
                //Rsession rs = Rsession.newInstanceTry(System.out,RserverConf.parse("R://localhost"));

                /*   Rsession rs = Rsession.newInstanceTry(System.out,RserverConf.parse("R://localhost"));
                           
                   rs.set("df", data); //create R variable from java one
                           
                   rs.save(new File("save.Rdata"), "df"); //save variables in .Rdata*/

                /*RConnection c;
                try {
                           
                        
                   c = new RConnection();
                           
                           
                           
                   double[] dataX = {1,4,5,8};
                   double[] dataY = {1,7,9,12};
                           
                   c.assign("x", dataX);
                   c.assign("y", dataY);
                           
                   //c.assign("z", datmat.getColumnElements(1));
                        
                           
                   //String[] d= c.eval("c(z)").asStrings();
                           
                   //System.out.println(d[1].toString());
                   System.out.println(Arrays.toString(datmat.getColumnElements(1)));
                        
                           
                } catch (RserveException e2) {
                   // TODO Auto-generated catch block
                   e2.printStackTrace();
                } catch (REngineException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
                }*/

                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

            }

        });
        okButton.setBounds(175, 72, 57, 23);
        contentPanel.add(okButton);
        okButton.setActionCommand("OK");
        getRootPane().setDefaultButton(okButton);
    }
    {
        JButton cancelButton = new JButton("Cancel");
        cancelButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                dispose();
            }
        });
        cancelButton.setBounds(242, 72, 74, 23);
        contentPanel.add(cancelButton);
        cancelButton.setActionCommand("Cancel");
    }

    cbX = new JComboBox();

    cbX.setBounds(128, 8, 104, 20);
    contentPanel.add(cbX);

    cbY = new JComboBox();
    cbY.setBounds(307, 8, 104, 20);
    contentPanel.add(cbY);

}

From source file:org.openadaptor.auxil.connector.ui.TableUIConnector.java

private JPanel createButtonPanel(String[] buttonNames) {
    int buttons = buttonNames.length;
    JPanel buttonPanel = new JPanel(new GridLayout(0, buttons));
    for (int i = 0; i < buttons; i++) {
        String cmd = buttonNames[i];
        JButton button = new JButton(cmd);
        button.setActionCommand(cmd);
        button.addActionListener(this);
        buttonPanel.add(button);/*from www. ja va  2s.  c  o m*/
    }
    return buttonPanel;
}

From source file:org.opendatakit.briefcase.ui.CharsetConverterDialog.java

/**
 * Create the dialog.//  www.j  a v a 2 s.  c  om
 */
public CharsetConverterDialog(Window owner) {
    super(owner, ModalityType.DOCUMENT_MODAL);
    setTitle(DIALOG_TITLE);
    setBounds(100, 100, 600, 530);
    getContentPane().setLayout(new BorderLayout());
    JPanel contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    GridBagLayout gbl_contentPanel = new GridBagLayout();
    contentPanel.setLayout(gbl_contentPanel);
    {
        JLabel lblNewLabel = new JLabel(SELECT_FILE_LABEL);
        GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
        gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
        gbc_lblNewLabel.gridwidth = 2;
        gbc_lblNewLabel.insets = new Insets(0, 0, 5, 0);
        gbc_lblNewLabel.gridx = 0;
        gbc_lblNewLabel.gridy = 0;
        contentPanel.add(lblNewLabel, gbc_lblNewLabel);
    }
    {
        tfFile = new JTextField();
        tfFile.setEditable(false);
        GridBagConstraints gbc_tfFile = new GridBagConstraints();
        gbc_tfFile.weightx = 1.0;
        gbc_tfFile.insets = new Insets(0, 0, 5, 5);
        gbc_tfFile.fill = GridBagConstraints.HORIZONTAL;
        gbc_tfFile.gridx = 0;
        gbc_tfFile.gridy = 1;
        contentPanel.add(tfFile, gbc_tfFile);
        tfFile.setColumns(10);
    }
    {
        JButton btnBrowse = new JButton(SELECT_FILE_BUTTON);
        btnBrowse.setActionCommand(BROWSE_COMMAND);
        btnBrowse.addActionListener(this);
        GridBagConstraints gbc_btnBrowse = new GridBagConstraints();
        gbc_btnBrowse.insets = new Insets(0, 0, 5, 0);
        gbc_btnBrowse.gridx = 1;
        gbc_btnBrowse.gridy = 1;
        contentPanel.add(btnBrowse, gbc_btnBrowse);
    }
    {
        JLabel lblEncoding = new JLabel(SELECT_SOURCE_ENCODING_LABEL);
        GridBagConstraints gbc_lblEncoding = new GridBagConstraints();
        gbc_lblEncoding.anchor = GridBagConstraints.WEST;
        gbc_lblEncoding.insets = new Insets(0, 0, 5, 5);
        gbc_lblEncoding.gridx = 0;
        gbc_lblEncoding.gridy = 2;
        contentPanel.add(lblEncoding, gbc_lblEncoding);
    }
    {
        listCharset = new JList<CharsetEntry>();
        listCharset.setVisibleRowCount(7);
        listCharset.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        GridBagConstraints gbc_cbCharset = new GridBagConstraints();
        gbc_cbCharset.gridwidth = 2;
        gbc_cbCharset.insets = new Insets(0, 0, 5, 0);
        gbc_cbCharset.fill = GridBagConstraints.BOTH;
        gbc_cbCharset.gridx = 0;
        gbc_cbCharset.gridy = 3;
        JScrollPane listScrollPane = new JScrollPane(listCharset);
        contentPanel.add(listScrollPane, gbc_cbCharset);
    }
    {
        JLabel lblPreview = new JLabel(PREVIEW_LABEL);
        GridBagConstraints gbc_lblPreview = new GridBagConstraints();
        gbc_lblPreview.anchor = GridBagConstraints.WEST;
        gbc_lblPreview.insets = new Insets(0, 0, 5, 5);
        gbc_lblPreview.gridx = 0;
        gbc_lblPreview.gridy = 4;
        contentPanel.add(lblPreview, gbc_lblPreview);
    }
    {
        JScrollPane scrollPane = new JScrollPane();
        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
        gbc_scrollPane.weighty = 1.0;
        gbc_scrollPane.weightx = 1.0;
        gbc_scrollPane.gridwidth = 2;
        gbc_scrollPane.fill = GridBagConstraints.BOTH;
        gbc_scrollPane.gridx = 0;
        gbc_scrollPane.gridy = 5;
        contentPanel.add(scrollPane, gbc_scrollPane);
        {
            previewArea = new JTextArea();
            previewArea.setLineWrap(true);
            previewArea.setRows(10);
            previewArea.setFont(UIManager.getDefaults().getFont("Label.font").deriveFont(Font.PLAIN));
            previewArea.setEditable(false);
            scrollPane.setViewportView(previewArea);
        }
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            cbOverride = new JCheckBox(REPLACE_EXISTING_FILE_LABEL);
            cbOverride.setSelected(false);
            buttonPane.add(cbOverride);
        }
        {
            JButton okButton = new JButton(CONVERT_BUTTON_LABEL);
            okButton.setActionCommand(CONVERT_COMMAND);
            okButton.addActionListener(this);
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            cancelButton = new JButton(CANCEL_BUTTON_LABEL);
            cancelButton.setActionCommand(CANCEL_COMMAND);
            cancelButton.addActionListener(this);
            buttonPane.add(cancelButton);
        }
    }
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Formats the specified button./*  w ww  . j a va2 s.c  o m*/
 * 
 * @param button The button to handle.
 * @param text The tool tip text.
 * @param actionID The action command id.
 */
private void formatButton(JButton button, String text, int actionID) {
    button.setOpaque(false);
    UIUtilities.unifiedButtonLookAndFeel(button);
    button.setBackground(UIUtilities.BACKGROUND_COLOR);
    button.setToolTipText(text);
    button.addActionListener(this);
    button.setActionCommand("" + actionID);
}

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java

/**
 * Creates a button./*from  w  ww . j  a v a  2  s  .  c  o  m*/
 *
 * @param text The text of the button.
 * @param actionID The action command id.
 * @return See above.
 */
private JButton createButton(String text, int actionID) {
    JButton b = new JButton(text);
    b.setActionCommand("" + actionID);
    b.addActionListener(this);
    b.setOpaque(false);
    UIUtilities.unifiedButtonLookAndFeel(b);
    return b;
}