Example usage for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW

List of usage examples for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW

Introduction

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

Prototype

int WHEN_IN_FOCUSED_WINDOW

To view the source code for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW.

Click Source Link

Document

Constant used for registerKeyboardAction that means that the command should be invoked when the receiving component is in the window that has the focus or is itself the focused component.

Usage

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

/**
 * Initialise the GUI elements to display the given item.
 *//*from w  w w  . j  ava 2 s  . c om*/
private void initGui() {
    this.setResizable(true);
    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    JPanel unmodifiableAttributesPanel = skinsFactory.createSkinnedJPanel("ObjectStaticAttributesPanel");
    unmodifiableAttributesPanel.setLayout(new GridBagLayout());
    JPanel metadataContainer = skinsFactory.createSkinnedJPanel("ObjectPropertiesMetadataPanel");
    metadataContainer.setLayout(new GridBagLayout());
    metadataButtonsContainer = skinsFactory.createSkinnedJPanel("ObjectPropertiesMetadataButtonsPanel");
    metadataButtonsContainer.setLayout(new GridBagLayout());

    // Fields to display unmodifiable object details.
    JLabel objectKeyLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectKeyLabel");
    objectKeyLabel.setText("Object key:");
    objectKeyTextField = skinsFactory.createSkinnedJTextField("ObjectKeyTextField");
    objectKeyTextField.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:");
    bucketLocationTextField = skinsFactory.createSkinnedJTextField("BucketLocationTextField");
    bucketLocationTextField.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);

    int row = 0;

    unmodifiableAttributesPanel.add(objectKeyLabel, new GridBagConstraints(0, row, 1, 1, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
    unmodifiableAttributesPanel.add(objectKeyTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    row++;
    unmodifiableAttributesPanel.add(objectContentLengthLabel, new GridBagConstraints(0, row, 1, 1, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
    unmodifiableAttributesPanel.add(objectContentLengthTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    row++;
    unmodifiableAttributesPanel.add(objectLastModifiedLabel, new GridBagConstraints(0, row, 1, 1, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
    unmodifiableAttributesPanel.add(objectLastModifiedTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    row++;
    unmodifiableAttributesPanel.add(objectETagLabel, new GridBagConstraints(0, row, 1, 1, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
    unmodifiableAttributesPanel.add(objectETagTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    row++;
    unmodifiableAttributesPanel.add(ownerNameLabel, new GridBagConstraints(0, row, 1, 1, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
    unmodifiableAttributesPanel.add(ownerNameTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    row++;
    unmodifiableAttributesPanel.add(ownerIdLabel, new GridBagConstraints(0, row, 1, 1, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
    unmodifiableAttributesPanel.add(ownerIdTextField, new GridBagConstraints(1, row, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    row++;
    unmodifiableAttributesPanel.add(bucketNameLabel, new GridBagConstraints(0, row, 1, 1, 0, 0,
            GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0));
    unmodifiableAttributesPanel.add(bucketLocationTextField, new GridBagConstraints(1, row, 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;

        public boolean isCellEditable(int row, int column) {
            return isModifyMode();
        }
    };

    metadataTableSorter = new TableSorter(objectMetadataTableModel);
    metadataTable = skinsFactory.createSkinnedJTable("MetadataTable");
    metadataTable.setModel(metadataTableSorter);
    metadataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting() && removeMetadataItemButton != null) {
                int row = metadataTable.getSelectedRow();
                removeMetadataItemButton.setEnabled(row >= 0);
            }
        }
    });

    metadataTableSorter.setTableHeader(metadataTable.getTableHeader());
    metadataTableSorter.setSortingStatus(0, TableSorter.ASCENDING);
    metadataContainer.add(new JScrollPane(metadataTable), new GridBagConstraints(0, 0, 1, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsHorizontalSpace, 0, 0));

    // Add/remove buttons for metadata table.
    removeMetadataItemButton = skinsFactory.createSkinnedJButton("ObjectPropertiesAddMetadataButton");
    removeMetadataItemButton.setEnabled(false);
    removeMetadataItemButton.setToolTipText("Remove the selected metadata item(s)");
    guiUtils.applyIcon(removeMetadataItemButton, "/images/nuvola/16x16/actions/viewmag-.png");
    removeMetadataItemButton.addActionListener(this);
    removeMetadataItemButton.setActionCommand("removeMetadataItem");
    addMetadataItemButton = skinsFactory.createSkinnedJButton("ObjectPropertiesAddMetadataButton");
    addMetadataItemButton.setToolTipText("Add a new metadata item");
    guiUtils.applyIcon(addMetadataItemButton, "/images/nuvola/16x16/actions/viewmag+.png");
    addMetadataItemButton.setActionCommand("addMetadataItem");
    addMetadataItemButton.addActionListener(this);
    metadataButtonsContainer.add(removeMetadataItemButton, new GridBagConstraints(0, 0, 1, 1, 0, 0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0));
    metadataButtonsContainer.add(addMetadataItemButton, new GridBagConstraints(1, 0, 1, 1, 0, 0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0));
    metadataContainer.add(metadataButtonsContainer, new GridBagConstraints(0, 1, 1, 1, 1, 0,
            GridBagConstraints.EAST, GridBagConstraints.NONE, insetsHorizontalSpace, 0, 0));
    metadataButtonsContainer.setVisible(false);

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

    // Cancel Button.
    cancelButton = null;
    cancelButton = skinsFactory.createSkinnedJButton("ObjectPropertiesCancelButton");
    cancelButton.setText("Cancel");
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);
    cancelButton.setVisible(false);

    // Recognize and handle ENTER, ESCAPE, PAGE_UP, and PAGE_DOWN key presses.
    this.getRootPane().setDefaultButton(okButton);
    this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),
            "ESCAPE");
    this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() {
        private static final long serialVersionUID = -7768790936535999307L;

        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    });
    this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("PAGE_UP"),
            "PAGE_UP");
    this.getRootPane().getActionMap().put("PAGE_UP", new AbstractAction() {
        private static final long serialVersionUID = -6324229423705756219L;

        public void actionPerformed(ActionEvent actionEvent) {
            previousObjectButton.doClick();
        }
    });
    this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("PAGE_DOWN"),
            "PAGE_DOWN");
    this.getRootPane().getActionMap().put("PAGE_DOWN", new AbstractAction() {
        private static final long serialVersionUID = -5808972377672449421L;

        public void actionPerformed(ActionEvent actionEvent) {
            nextObjectButton.doClick();
        }
    });

    // Put it all together.
    row = 0;
    JPanel container = skinsFactory.createSkinnedJPanel("ObjectPropertiesPanel");
    container.setLayout(new GridBagLayout());
    container.add(unmodifiableAttributesPanel, new GridBagConstraints(0, row++, 1, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    // Object previous and next buttons, if we have multiple objects.
    previousObjectButton = skinsFactory.createSkinnedJButton("ObjectPropertiesPreviousButton");
    guiUtils.applyIcon(previousObjectButton, "/images/nuvola/16x16/actions/1leftarrow.png");
    previousObjectButton.addActionListener(this);
    previousObjectButton.setEnabled(false);
    nextObjectButton = skinsFactory.createSkinnedJButton("ObjectPropertiesNextButton");
    guiUtils.applyIcon(nextObjectButton, "/images/nuvola/16x16/actions/1rightarrow.png");
    nextObjectButton.addActionListener(this);
    nextObjectButton.setEnabled(false);
    currentObjectLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectPropertiesCurrentObjectLabel");
    currentObjectLabel.setHorizontalAlignment(JLabel.CENTER);

    nextPreviousPanel = skinsFactory.createSkinnedJPanel("ObjectPropertiesNextPreviousPanel");
    nextPreviousPanel.setLayout(new GridBagLayout());
    nextPreviousPanel.add(previousObjectButton, new GridBagConstraints(0, 0, 1, 1, 1, 0,
            GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0));
    nextPreviousPanel.add(currentObjectLabel, new GridBagConstraints(1, 0, 1, 1, 0, 0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsHorizontalSpace, 0, 0));
    nextPreviousPanel.add(nextObjectButton, new GridBagConstraints(2, 0, 1, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    container.add(nextPreviousPanel, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    nextPreviousPanel.setVisible(false);
    row++;

    JHtmlLabel metadataLabel = skinsFactory.createSkinnedJHtmlLabel("MetadataLabel");
    metadataLabel.setText("<html><b>Metadata Attributes</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));

    // Destination Access Control List setting.
    destinationPanel = skinsFactory.createSkinnedJPanel("DestinationPanel");
    destinationPanel.setLayout(new GridBagLayout());

    JPanel actionButtonsPanel = skinsFactory.createSkinnedJPanel("ObjectPropertiesActionButtonsPanel");
    actionButtonsPanel.setLayout(new GridBagLayout());
    actionButtonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    actionButtonsPanel.add(okButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    cancelButton.setVisible(false);

    container.add(actionButtonsPanel, new GridBagConstraints(0, row++, 3, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
    this.getContentPane().add(container);

    this.pack();
    this.setSize(new Dimension(450, 500));
    this.setLocationRelativeTo(this.getOwner());
}

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

private void initGui() {
    // Initialise skins factory.
    skinsFactory = SkinsFactory.getInstance(applicationProperties);

    // Set Skinned Look and Feel.
    LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel");
    try {/*from ww  w .  ja va2  s. c om*/
        UIManager.setLookAndFeel(lookAndFeel);
    } catch (UnsupportedLookAndFeelException e) {
        log.error("Unable to set skinned LookAndFeel", e);
    }

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

    JPanel container = new JPanel(new GridBagLayout());

    statusMessageLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressDialogStatusMessageLabel");
    statusMessageLabel.setText(" ");
    statusMessageLabel.setHorizontalAlignment(JLabel.CENTER);
    container.add(statusMessageLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    progressBar = skinsFactory.createSkinnedJProgressBar("ProgressDialogProgressBar", 0, 100);
    progressBar.setPreferredSize(new Dimension(550, 20));

    container.add(progressBar, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    detailsTextLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressDialogDetailedMessageLabel");
    detailsTextLabel.setText(" ");
    detailsTextLabel.setHorizontalAlignment(JLabel.CENTER);
    container.add(detailsTextLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    // Display the cancel button if a cancel event listener is available.
    cancelButton = skinsFactory.createSkinnedJButton("ProgressDialogCancelButton");
    cancelButton.setText("Cancel");
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);
    cancelButton.setDefaultCapable(true);

    container.add(cancelButton, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, insetsDefault, 0, 0));

    // Set Cancel as the default operation when ESCAPE is pressed.
    this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),
            "ESCAPE");
    this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() {
        private static final long serialVersionUID = 4397881858674185924L;

        public void actionPerformed(ActionEvent actionEvent) {
            cancelButton.doClick();
        }
    });

    this.getContentPane().add(container);

    this.pack();
    this.setLocationRelativeTo(this.getOwner());
}

From source file:org.kse.gui.crypto.DUpgradeCryptoStrength.java

private void initComponents() {

    jlUpgradeInstructions = new JLabel(res.getString("DUpgradeCryptoStrength.jlUpgradeInstructions.text"));
    jlDownloadPolicyInstructions = new JLabel(
            res.getString("DUpgradeCryptoStrength.jlDownloadPolicyInstructions.text"));
    jbDownloadPolicy = new JButton(res.getString("DUpgradeCryptoStrength.jbDownloadPolicy.text"));
    PlatformUtil.setMnemonic(jbDownloadPolicy,
            res.getString("DUpgradeCryptoStrength.jbDownloadPolicy.mnemonic").charAt(0));

    jlDropPolicyInstructions = new JLabel(
            res.getString("DUpgradeCryptoStrength.jlDropPolicyInstructions.text"));
    policyZipDropTarget = new PolicyZipDropTarget();
    jbBrowsePolicy = new JButton(res.getString("DUpgradeCryptoStrength.jbBrowsePolicy.text"));
    PlatformUtil.setMnemonic(jbBrowsePolicy,
            res.getString("DUpgradeCryptoStrength.jbBrowsePolicy.mnemonic").charAt(0));

    jbUpgrade = new JButton(res.getString("DUpgradeCryptoStrength.jbUpgrade.text"));
    PlatformUtil.setMnemonic(jbUpgrade, res.getString("DUpgradeCryptoStrength.jbUpgrade.mnemonic").charAt(0));
    jbUpgrade.setEnabled(false);/*from  w  w w .  j ava2s. com*/

    jbCancel = new JButton(res.getString("DUpgradeCryptoStrength.jbCancel.text"));
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);

    jpButtons = PlatformUtil.createDialogButtonPanel(jbUpgrade, jbCancel);

    // layout
    Container pane = getContentPane();
    pane.setLayout(new MigLayout("insets dialog, fill", "", "[]para[]"));
    pane.add(jlUpgradeInstructions, "wrap");
    pane.add(jlDownloadPolicyInstructions, "wrap");
    pane.add(jbDownloadPolicy, "wrap");
    pane.add(jlDropPolicyInstructions, "split");
    pane.add(policyZipDropTarget, "gap para, pad para, wrap");
    pane.add(jbBrowsePolicy, "wrap");
    pane.add(new JSeparator(), "spanx, growx, wrap para");
    pane.add(jpButtons, "right, spanx");

    // actions
    jbDownloadPolicy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DUpgradeCryptoStrength.this);
                downloadPolicyPressed();
            } finally {
                CursorUtil.setCursorFree(DUpgradeCryptoStrength.this);
            }
        }
    });
    jbUpgrade.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            upgradePressed();
        }
    });
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbBrowsePolicy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DUpgradeCryptoStrength.this);
                browsePolicyPressed();
            } finally {
                CursorUtil.setCursorFree(DUpgradeCryptoStrength.this);
            }
        }
    });
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    setResizable(false);

    getRootPane().setDefaultButton(jbUpgrade);

    pack();
}

From source file:org.kse.gui.dialogs.DCheckUpdate.java

private void initComponents() {
    jlCheckUpdate = new JLabel(res.getString("DCheckUpdate.jlCheckUpdate.text"));
    ImageIcon icon = new ImageIcon(getClass().getResource(res.getString("DCheckUpdate.jlCheckUpdate.image")));
    jlCheckUpdate.setIcon(icon);/*  w ww. j a v a  2 s.  c  o  m*/
    jlCheckUpdate.setHorizontalTextPosition(SwingConstants.LEADING);
    jlCheckUpdate.setIconTextGap(15);

    jpCheckUpdate = new JPanel(new FlowLayout(FlowLayout.CENTER));
    jpCheckUpdate.add(jlCheckUpdate);
    jpCheckUpdate.setBorder(new EmptyBorder(5, 5, 5, 5));

    jpbCheckUpdate = new JProgressBar();
    jpbCheckUpdate.setIndeterminate(true);
    jpbCheckUpdate.setString("DCheckUpdate.jlCheckUpdate.text");

    jpProgress = new JPanel(new FlowLayout(FlowLayout.CENTER));
    jpProgress.add(jpbCheckUpdate);
    jpProgress.setBorder(new EmptyBorder(5, 5, 5, 5));

    jbCancel = new JButton(res.getString("DCheckUpdate.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    jpCancel = PlatformUtil.createDialogButtonPanel(jbCancel, false);

    getContentPane().add(jpCheckUpdate, BorderLayout.NORTH);
    getContentPane().add(jpProgress, BorderLayout.CENTER);
    getContentPane().add(jpCancel, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            if ((checker != null) && (checker.isAlive())) {
                checker.interrupt();
            }
            closeDialog();
        }
    });

    setTitle(res.getString("DCheckUpdate.Title"));
    setResizable(false);

    pack();
}

From source file:org.kse.gui.dialogs.importexport.DImportKeyPairOpenSsl.java

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;/*from ww  w .j  a  v a2s. c o m*/
    gbcLbl.gridwidth = 3;
    gbcLbl.gridheight = 1;
    gbcLbl.insets = new Insets(5, 5, 5, 5);
    gbcLbl.anchor = GridBagConstraints.EAST;

    GridBagConstraints gbcEdCtrl = new GridBagConstraints();
    gbcEdCtrl.gridx = 3;
    gbcEdCtrl.gridwidth = 3;
    gbcEdCtrl.gridheight = 1;
    gbcEdCtrl.insets = new Insets(5, 5, 5, 5);
    gbcEdCtrl.anchor = GridBagConstraints.WEST;

    jlEncrypted = new JLabel(res.getString("DImportKeyPairOpenSsl.jlEncrypted.text"));
    GridBagConstraints gbc_jlEncrypted = (GridBagConstraints) gbcLbl.clone();
    gbc_jlEncrypted.gridy = 0;

    jcbEncrypted = new JCheckBox();
    jcbEncrypted.setSelected(true);
    jcbEncrypted.setToolTipText(res.getString("DImportKeyPairOpenSsl.jcbEncrypted.tooltip"));
    GridBagConstraints gbc_jcbEncrypted = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jcbEncrypted.gridy = 0;

    jlPassword = new JLabel(res.getString("DImportKeyPairOpenSsl.jlPassword.text"));
    GridBagConstraints gbc_jlPassword = (GridBagConstraints) gbcLbl.clone();
    gbc_jlPassword.gridy = 1;

    jpfPassword = new JPasswordField(15);
    jpfPassword.setToolTipText(res.getString("DImportKeyPairOpenSsl.jpfPassword.tooltip"));
    GridBagConstraints gbc_jpfPassword = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jpfPassword.gridy = 1;

    jlPrivateKey = new JLabel(res.getString("DImportKeyPairOpenSsl.jlPrivateKey.text"));
    GridBagConstraints gbc_jlPrivateKey = (GridBagConstraints) gbcLbl.clone();
    gbc_jlPrivateKey.gridy = 2;

    jtfPrivateKeyPath = new JTextField(30);
    jtfPrivateKeyPath.setToolTipText(res.getString("DImportKeyPairOpenSsl.jtfPrivateKeyPath.tooltip"));
    GridBagConstraints gbc_jtfPrivateKeyPath = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jtfPrivateKeyPath.gridy = 2;
    gbc_jtfPrivateKeyPath.gridwidth = 6;

    jbPrivateKeyBrowse = new JButton(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyBrowse.text"));
    PlatformUtil.setMnemonic(jbPrivateKeyBrowse,
            res.getString("DImportKeyPairOpenSsl.jbPrivateKeyBrowse.mnemonic").charAt(0));
    jbPrivateKeyBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this);
                privateKeyBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this);
            }
        }
    });
    jbPrivateKeyBrowse.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyBrowse.tooltip"));
    GridBagConstraints gbc_jbPrivateKeyBrowse = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbPrivateKeyBrowse.gridy = 2;
    gbc_jbPrivateKeyBrowse.gridx = 9;

    jbPrivateKeyDetails = new JButton(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyDetails.text"));
    jbPrivateKeyDetails.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this);
                privateKeyDetailsPressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this);
            }
        }
    });
    PlatformUtil.setMnemonic(jbPrivateKeyDetails,
            res.getString("DImportKeyPairOpenSsl.jbPrivateKeyDetails.mnemonic").charAt(0));
    jbPrivateKeyDetails.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbPrivateKeyDetails.tooltip"));
    GridBagConstraints gbc_jbPrivateKeyDetails = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbPrivateKeyDetails.gridy = 2;
    gbc_jbPrivateKeyDetails.gridx = 12;

    jlCertificate = new JLabel(res.getString("DImportKeyPairOpenSsl.jlCertificate.text"));
    GridBagConstraints gbc_jlCertificate = (GridBagConstraints) gbcLbl.clone();
    gbc_jlCertificate.gridy = 3;

    jtfCertificatePath = new JTextField(30);
    jtfCertificatePath.setToolTipText(res.getString("DImportKeyPairOpenSsl.jtfCertificatePath.tooltip"));
    GridBagConstraints gbc_jtfCertificatePath = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jtfCertificatePath.gridy = 3;
    gbc_jtfCertificatePath.gridwidth = 6;

    jbCertificateBrowse = new JButton(res.getString("DImportKeyPairOpenSsl.jbCertificateBrowse.text"));
    jbCertificateBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this);
                certificateBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this);
            }
        }
    });
    PlatformUtil.setMnemonic(jbCertificateBrowse,
            res.getString("DImportKeyPairOpenSsl.jbCertificateBrowse.mnemonic").charAt(0));
    jbCertificateBrowse.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbCertificateBrowse.tooltip"));
    GridBagConstraints gbc_jbCertificateBrowse = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbCertificateBrowse.gridy = 3;
    gbc_jbCertificateBrowse.gridx = 9;

    jbCertificateDetails = new JButton(res.getString("DImportKeyPairOpenSsl.jbCertificateDetails.text"));
    jbCertificateDetails.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this);
                certificateDetailsPressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this);
            }
        }
    });
    PlatformUtil.setMnemonic(jbCertificateDetails,
            res.getString("DImportKeyPairOpenSsl.jbCertificateDetails.mnemonic").charAt(0));
    jbCertificateDetails.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbCertificateDetails.tooltip"));
    GridBagConstraints gbc_jbCertificateDetails = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbCertificateDetails.gridy = 3;
    gbc_jbCertificateDetails.gridx = 12;

    jpKeyPair = new JPanel(new GridBagLayout());
    jpKeyPair.setBorder(new CompoundBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()),
            new EmptyBorder(5, 5, 5, 5)));

    jpKeyPair.add(jlEncrypted, gbc_jlEncrypted);
    jpKeyPair.add(jcbEncrypted, gbc_jcbEncrypted);
    jpKeyPair.add(jlPassword, gbc_jlPassword);
    jpKeyPair.add(jpfPassword, gbc_jpfPassword);
    jpKeyPair.add(jlPrivateKey, gbc_jlPrivateKey);
    jpKeyPair.add(jtfPrivateKeyPath, gbc_jtfPrivateKeyPath);
    jpKeyPair.add(jbPrivateKeyBrowse, gbc_jbPrivateKeyBrowse);
    jpKeyPair.add(jbPrivateKeyDetails, gbc_jbPrivateKeyDetails);
    jpKeyPair.add(jlCertificate, gbc_jlCertificate);
    jpKeyPair.add(jtfCertificatePath, gbc_jtfCertificatePath);
    jpKeyPair.add(jbCertificateBrowse, gbc_jbCertificateBrowse);
    jpKeyPair.add(jbCertificateDetails, gbc_jbCertificateDetails);

    jcbEncrypted.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent evt) {
            if (jcbEncrypted.isSelected()) {
                jpfPassword.setEnabled(true);
            } else {
                jpfPassword.setEnabled(false);
                jpfPassword.setText("");
            }
        }
    });

    jbImport = new JButton(res.getString("DImportKeyPairOpenSsl.jbImport.text"));
    PlatformUtil.setMnemonic(jbImport, res.getString("DImportKeyPairOpenSsl.jbImport.mnemonic").charAt(0));
    jbImport.setToolTipText(res.getString("DImportKeyPairOpenSsl.jbImport.tooltip"));
    jbImport.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairOpenSsl.this);
                importPressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairOpenSsl.this);
            }
        }
    });

    jbCancel = new JButton(res.getString("DImportKeyPairOpenSsl.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    jpButtons = PlatformUtil.createDialogButtonPanel(jbImport, jbCancel);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(jpKeyPair, BorderLayout.CENTER);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    setTitle(res.getString("DImportKeyPairOpenSsl.Title"));
    setResizable(false);

    getRootPane().setDefaultButton(jbImport);

    pack();
}

From source file:org.kse.gui.dialogs.importexport.DImportKeyPairPkcs8.java

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;//from   ww w. j a  va  2 s  . c  om
    gbcLbl.gridwidth = 3;
    gbcLbl.gridheight = 1;
    gbcLbl.insets = new Insets(5, 5, 5, 5);
    gbcLbl.anchor = GridBagConstraints.EAST;

    GridBagConstraints gbcEdCtrl = new GridBagConstraints();
    gbcEdCtrl.gridx = 3;
    gbcEdCtrl.gridwidth = 3;
    gbcEdCtrl.gridheight = 1;
    gbcEdCtrl.insets = new Insets(5, 5, 5, 5);
    gbcEdCtrl.anchor = GridBagConstraints.WEST;

    jlEncrypted = new JLabel(res.getString("DImportKeyPairPkcs8.jlEncrypted.text"));
    GridBagConstraints gbc_jlEncrypted = (GridBagConstraints) gbcLbl.clone();
    gbc_jlEncrypted.gridy = 0;

    jcbEncrypted = new JCheckBox();
    jcbEncrypted.setSelected(true);
    jcbEncrypted.setToolTipText(res.getString("DImportKeyPairPkcs8.jcbEncrypted.tooltip"));
    GridBagConstraints gbc_jcbEncrypted = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jcbEncrypted.gridy = 0;

    jlPassword = new JLabel(res.getString("DImportKeyPairPkcs8.jlPassword.text"));
    GridBagConstraints gbc_jlPassword = (GridBagConstraints) gbcLbl.clone();
    gbc_jlPassword.gridy = 1;

    jpfPassword = new JPasswordField(15);
    jpfPassword.setToolTipText(res.getString("DImportKeyPairPkcs8.jpfPassword.tooltip"));
    GridBagConstraints gbc_jpfPassword = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jpfPassword.gridy = 1;

    jlPrivateKey = new JLabel(res.getString("DImportKeyPairPkcs8.jlPrivateKey.text"));
    GridBagConstraints gbc_jlPrivateKey = (GridBagConstraints) gbcLbl.clone();
    gbc_jlPrivateKey.gridy = 2;

    jtfPrivateKeyPath = new JTextField(30);
    jtfPrivateKeyPath.setToolTipText(res.getString("DImportKeyPairPkcs8.jtfPrivateKeyPath.tooltip"));
    GridBagConstraints gbc_jtfPrivateKeyPath = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jtfPrivateKeyPath.gridy = 2;
    gbc_jtfPrivateKeyPath.gridwidth = 6;

    jbPrivateKeyBrowse = new JButton(res.getString("DImportKeyPairPkcs8.jbPrivateKeyBrowse.text"));
    PlatformUtil.setMnemonic(jbPrivateKeyBrowse,
            res.getString("DImportKeyPairPkcs8.jbPrivateKeyBrowse.mnemonic").charAt(0));
    jbPrivateKeyBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairPkcs8.this);
                privateKeyBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairPkcs8.this);
            }
        }
    });
    jbPrivateKeyBrowse.setToolTipText(res.getString("DImportKeyPairPkcs8.jbPrivateKeyBrowse.tooltip"));
    GridBagConstraints gbc_jbPrivateKeyBrowse = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbPrivateKeyBrowse.gridy = 2;
    gbc_jbPrivateKeyBrowse.gridx = 9;

    jbPrivateKeyDetails = new JButton(res.getString("DImportKeyPairPkcs8.jbPrivateKeyDetails.text"));
    jbPrivateKeyDetails.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairPkcs8.this);
                privateKeyDetailsPressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairPkcs8.this);
            }
        }
    });
    PlatformUtil.setMnemonic(jbPrivateKeyDetails,
            res.getString("DImportKeyPairPkcs8.jbPrivateKeyDetails.mnemonic").charAt(0));
    jbPrivateKeyDetails.setToolTipText(res.getString("DImportKeyPairPkcs8.jbPrivateKeyDetails.tooltip"));
    GridBagConstraints gbc_jbPrivateKeyDetails = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbPrivateKeyDetails.gridy = 2;
    gbc_jbPrivateKeyDetails.gridx = 12;

    jlCertificate = new JLabel(res.getString("DImportKeyPairPkcs8.jlCertificate.text"));
    GridBagConstraints gbc_jlCertificate = (GridBagConstraints) gbcLbl.clone();
    gbc_jlCertificate.gridy = 3;

    jtfCertificatePath = new JTextField(30);
    jtfCertificatePath.setToolTipText(res.getString("DImportKeyPairPkcs8.jtfCertificatePath.tooltip"));
    GridBagConstraints gbc_jtfCertificatePath = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jtfCertificatePath.gridy = 3;
    gbc_jtfCertificatePath.gridwidth = 6;

    jbCertificateBrowse = new JButton(res.getString("DImportKeyPairPkcs8.jbCertificateBrowse.text"));
    jbCertificateBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairPkcs8.this);
                certificateBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairPkcs8.this);
            }
        }
    });
    PlatformUtil.setMnemonic(jbCertificateBrowse,
            res.getString("DImportKeyPairPkcs8.jbCertificateBrowse.mnemonic").charAt(0));
    jbCertificateBrowse.setToolTipText(res.getString("DImportKeyPairPkcs8.jbCertificateBrowse.tooltip"));
    GridBagConstraints gbc_jbCertificateBrowse = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbCertificateBrowse.gridy = 3;
    gbc_jbCertificateBrowse.gridx = 9;

    jbCertificateDetails = new JButton(res.getString("DImportKeyPairPkcs8.jbCertificateDetails.text"));
    jbCertificateDetails.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairPkcs8.this);
                certificateDetailsPressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairPkcs8.this);
            }
        }
    });
    PlatformUtil.setMnemonic(jbCertificateDetails,
            res.getString("DImportKeyPairPkcs8.jbCertificateDetails.mnemonic").charAt(0));
    jbCertificateDetails.setToolTipText(res.getString("DImportKeyPairPkcs8.jbCertificateDetails.tooltip"));
    GridBagConstraints gbc_jbCertificateDetails = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbCertificateDetails.gridy = 3;
    gbc_jbCertificateDetails.gridx = 12;

    jpKeyPair = new JPanel(new GridBagLayout());
    jpKeyPair.setBorder(new CompoundBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()),
            new EmptyBorder(5, 5, 5, 5)));

    jpKeyPair.add(jlEncrypted, gbc_jlEncrypted);
    jpKeyPair.add(jcbEncrypted, gbc_jcbEncrypted);
    jpKeyPair.add(jlPassword, gbc_jlPassword);
    jpKeyPair.add(jpfPassword, gbc_jpfPassword);
    jpKeyPair.add(jlPrivateKey, gbc_jlPrivateKey);
    jpKeyPair.add(jtfPrivateKeyPath, gbc_jtfPrivateKeyPath);
    jpKeyPair.add(jbPrivateKeyBrowse, gbc_jbPrivateKeyBrowse);
    jpKeyPair.add(jbPrivateKeyDetails, gbc_jbPrivateKeyDetails);
    jpKeyPair.add(jlCertificate, gbc_jlCertificate);
    jpKeyPair.add(jtfCertificatePath, gbc_jtfCertificatePath);
    jpKeyPair.add(jbCertificateBrowse, gbc_jbCertificateBrowse);
    jpKeyPair.add(jbCertificateDetails, gbc_jbCertificateDetails);

    jcbEncrypted.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent evt) {
            if (jcbEncrypted.isSelected()) {
                jpfPassword.setEnabled(true);
            } else {
                jpfPassword.setEnabled(false);
                jpfPassword.setText("");
            }
        }
    });

    jbImport = new JButton(res.getString("DImportKeyPairPkcs8.jbImport.text"));
    PlatformUtil.setMnemonic(jbImport, res.getString("DImportKeyPairPkcs8.jbImport.mnemonic").charAt(0));
    jbImport.setToolTipText(res.getString("DImportKeyPairPkcs8.jbImport.tooltip"));
    jbImport.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairPkcs8.this);
                importPressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairPkcs8.this);
            }
        }
    });

    jbCancel = new JButton(res.getString("DImportKeyPairPkcs8.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    jpButtons = PlatformUtil.createDialogButtonPanel(jbImport, jbCancel);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(jpKeyPair, BorderLayout.CENTER);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    setTitle(res.getString("DImportKeyPairPkcs8.Title"));
    setResizable(false);

    getRootPane().setDefaultButton(jbImport);

    pack();
}

From source file:org.kse.gui.dialogs.importexport.DImportKeyPairPvk.java

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;// w  w  w  .  java 2 s. com
    gbcLbl.gridwidth = 3;
    gbcLbl.gridheight = 1;
    gbcLbl.insets = new Insets(5, 5, 5, 5);
    gbcLbl.anchor = GridBagConstraints.EAST;

    GridBagConstraints gbcEdCtrl = new GridBagConstraints();
    gbcEdCtrl.gridx = 3;
    gbcEdCtrl.gridwidth = 3;
    gbcEdCtrl.gridheight = 1;
    gbcEdCtrl.insets = new Insets(5, 5, 5, 5);
    gbcEdCtrl.anchor = GridBagConstraints.WEST;

    jlEncrypted = new JLabel(res.getString("DImportKeyPairPvk.jlEncrypted.text"));
    GridBagConstraints gbc_jlEncrypted = (GridBagConstraints) gbcLbl.clone();
    gbc_jlEncrypted.gridy = 0;

    jcbEncrypted = new JCheckBox();
    jcbEncrypted.setSelected(true);
    jcbEncrypted.setToolTipText(res.getString("DImportKeyPairPvk.jcbEncrypted.tooltip"));
    GridBagConstraints gbc_jcbEncrypted = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jcbEncrypted.gridy = 0;

    jlPassword = new JLabel(res.getString("DImportKeyPairPvk.jlPassword.text"));
    GridBagConstraints gbc_jlPassword = (GridBagConstraints) gbcLbl.clone();
    gbc_jlPassword.gridy = 1;

    jpfPassword = new JPasswordField(15);
    jpfPassword.setToolTipText(res.getString("DImportKeyPairPvk.jpfPassword.tooltip"));
    GridBagConstraints gbc_jpfPassword = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jpfPassword.gridy = 1;

    jlPrivateKey = new JLabel(res.getString("DImportKeyPairPvk.jlPrivateKey.text"));
    GridBagConstraints gbc_jlPrivateKey = (GridBagConstraints) gbcLbl.clone();
    gbc_jlPrivateKey.gridy = 2;

    jtfPrivateKeyPath = new JTextField(30);
    jtfPrivateKeyPath.setToolTipText(res.getString("DImportKeyPairPvk.jtfPrivateKeyPath.tooltip"));
    GridBagConstraints gbc_jtfPrivateKeyPath = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jtfPrivateKeyPath.gridy = 2;
    gbc_jtfPrivateKeyPath.gridwidth = 6;

    jbPrivateKeyBrowse = new JButton(res.getString("DImportKeyPairPvk.jbPrivateKeyBrowse.text"));
    PlatformUtil.setMnemonic(jbPrivateKeyBrowse,
            res.getString("DImportKeyPairPvk.jbPrivateKeyBrowse.mnemonic").charAt(0));
    jbPrivateKeyBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairPvk.this);
                privateKeyBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairPvk.this);
            }
        }
    });
    jbPrivateKeyBrowse.setToolTipText(res.getString("DImportKeyPairPvk.jbPrivateKeyBrowse.tooltip"));
    GridBagConstraints gbc_jbPrivateKeyBrowse = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbPrivateKeyBrowse.gridy = 2;
    gbc_jbPrivateKeyBrowse.gridx = 9;

    jbPrivateKeyDetails = new JButton(res.getString("DImportKeyPairPvk.jbPrivateKeyDetails.text"));
    jbPrivateKeyDetails.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairPvk.this);
                privateKeyDetailsPressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairPvk.this);
            }
        }
    });
    PlatformUtil.setMnemonic(jbPrivateKeyDetails,
            res.getString("DImportKeyPairPvk.jbPrivateKeyDetails.mnemonic").charAt(0));
    jbPrivateKeyDetails.setToolTipText(res.getString("DImportKeyPairPvk.jbPrivateKeyDetails.tooltip"));
    GridBagConstraints gbc_jbPrivateKeyDetails = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbPrivateKeyDetails.gridy = 2;
    gbc_jbPrivateKeyDetails.gridx = 12;

    jlCertificate = new JLabel(res.getString("DImportKeyPairPvk.jlCertificate.text"));
    GridBagConstraints gbc_jlCertificate = (GridBagConstraints) gbcLbl.clone();
    gbc_jlCertificate.gridy = 3;

    jtfCertificatePath = new JTextField(30);
    jtfCertificatePath.setToolTipText(res.getString("DImportKeyPairPvk.jtfCertificatePath.tooltip"));
    GridBagConstraints gbc_jtfCertificatePath = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jtfCertificatePath.gridy = 3;
    gbc_jtfCertificatePath.gridwidth = 6;

    jbCertificateBrowse = new JButton(res.getString("DImportKeyPairPvk.jbCertificateBrowse.text"));
    jbCertificateBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairPvk.this);
                certificateBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairPvk.this);
            }
        }
    });
    PlatformUtil.setMnemonic(jbCertificateBrowse,
            res.getString("DImportKeyPairPvk.jbCertificateBrowse.mnemonic").charAt(0));
    jbCertificateBrowse.setToolTipText(res.getString("DImportKeyPairPvk.jbCertificateBrowse.tooltip"));
    GridBagConstraints gbc_jbCertificateBrowse = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbCertificateBrowse.gridy = 3;
    gbc_jbCertificateBrowse.gridx = 9;

    jbCertificateDetails = new JButton(res.getString("DImportKeyPairPvk.jbCertificateDetails.text"));
    jbCertificateDetails.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairPvk.this);
                certificateDetailsPressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairPvk.this);
            }
        }
    });
    PlatformUtil.setMnemonic(jbCertificateDetails,
            res.getString("DImportKeyPairPvk.jbCertificateDetails.mnemonic").charAt(0));
    jbCertificateDetails.setToolTipText(res.getString("DImportKeyPairPvk.jbCertificateDetails.tooltip"));
    GridBagConstraints gbc_jbCertificateDetails = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbCertificateDetails.gridy = 3;
    gbc_jbCertificateDetails.gridx = 12;

    jpKeyPair = new JPanel(new GridBagLayout());
    jpKeyPair.setBorder(new CompoundBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()),
            new EmptyBorder(5, 5, 5, 5)));

    jpKeyPair.add(jlEncrypted, gbc_jlEncrypted);
    jpKeyPair.add(jcbEncrypted, gbc_jcbEncrypted);
    jpKeyPair.add(jlPassword, gbc_jlPassword);
    jpKeyPair.add(jpfPassword, gbc_jpfPassword);
    jpKeyPair.add(jlPrivateKey, gbc_jlPrivateKey);
    jpKeyPair.add(jtfPrivateKeyPath, gbc_jtfPrivateKeyPath);
    jpKeyPair.add(jbPrivateKeyBrowse, gbc_jbPrivateKeyBrowse);
    jpKeyPair.add(jbPrivateKeyDetails, gbc_jbPrivateKeyDetails);
    jpKeyPair.add(jlCertificate, gbc_jlCertificate);
    jpKeyPair.add(jtfCertificatePath, gbc_jtfCertificatePath);
    jpKeyPair.add(jbCertificateBrowse, gbc_jbCertificateBrowse);
    jpKeyPair.add(jbCertificateDetails, gbc_jbCertificateDetails);

    jcbEncrypted.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent evt) {
            if (jcbEncrypted.isSelected()) {
                jpfPassword.setEnabled(true);
            } else {
                jpfPassword.setEnabled(false);
                jpfPassword.setText("");
            }
        }
    });

    jbImport = new JButton(res.getString("DImportKeyPairPvk.jbImport.text"));
    PlatformUtil.setMnemonic(jbImport, res.getString("DImportKeyPairPvk.jbImport.mnemonic").charAt(0));
    jbImport.setToolTipText(res.getString("DImportKeyPairPvk.jbImport.tooltip"));
    jbImport.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DImportKeyPairPvk.this);
                importPressed();
            } finally {
                CursorUtil.setCursorFree(DImportKeyPairPvk.this);
            }
        }
    });

    jbCancel = new JButton(res.getString("DImportKeyPairPvk.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    jpButtons = PlatformUtil.createDialogButtonPanel(jbImport, jbCancel);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(jpKeyPair, BorderLayout.CENTER);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    setTitle(res.getString("DImportKeyPairPvk.Title"));
    setResizable(false);

    getRootPane().setDefaultButton(jbImport);

    pack();
}

From source file:org.kse.gui.dialogs.sign.DSignJar.java

private void initComponents(String signatureName) throws CryptoException {

    jlInputJar = new JLabel(res.getString("DSignJar.jlInputJar.text"));
    jtfInputJar = new JTextField(30);
    jtfInputJar.setCaretPosition(0);//from  ww w.j  a v a2 s  . c  om
    jtfInputJar.setToolTipText(res.getString("DSignJar.jtfInputJar.tooltip"));

    jbInputJarBrowse = new JButton(res.getString("DSignJar.jbInputJarBrowse.text"));
    PlatformUtil.setMnemonic(jbInputJarBrowse, res.getString("DSignJar.jbInputJarBrowse.mnemonic").charAt(0));
    jbInputJarBrowse.setToolTipText(res.getString("DSignJar.jbInputJarBrowse.tooltip"));

    jlSignDirectly = new JLabel(res.getString("DSignJar.jlSignDirectly.text"));
    jcbSignDirectly = new JCheckBox();
    jcbSignDirectly.setSelected(true);
    jcbSignDirectly.setToolTipText(res.getString("DSignJar.jcbSignDirectly.tooltip"));

    jlOutputJar = new JLabel(res.getString("DSignJar.jlOutputJar.text"));
    jtfOutputJar = new JTextField(30);
    jtfOutputJar.setEnabled(false);
    jtfOutputJar.setCaretPosition(0);
    jtfOutputJar.setToolTipText(res.getString("DSignJar.jtfOutputJar.tooltip"));

    jbOutputJarBrowse = new JButton(res.getString("DSignJar.jbOutputJarBrowse.text"));
    PlatformUtil.setMnemonic(jbOutputJarBrowse, res.getString("DSignJar.jbOutputJarBrowse.mnemonic").charAt(0));
    jbOutputJarBrowse.setToolTipText(res.getString("DSignJar.jbOutputJarBrowse.tooltip"));
    jbOutputJarBrowse.setEnabled(false);

    jlSignatureName = new JLabel(res.getString("DSignJar.jlSignatureName.text"));
    jtfSignatureName = new JTextField(convertSignatureName(signatureName), 15);
    jtfSignatureName.setCaretPosition(0);
    jtfSignatureName.setToolTipText(res.getString("DSignJar.jtfSignatureName.tooltip"));

    jlSignatureAlgorithm = new JLabel(res.getString("DSignJar.jlSignatureAlgorithm.text"));
    jcbSignatureAlgorithm = new JComboBox<SignatureType>();
    DialogHelper.populateSigAlgs(signKeyPairType, this.signPrivateKey, provider, jcbSignatureAlgorithm);
    jcbSignatureAlgorithm.setToolTipText(res.getString("DSignJar.jcbSignatureAlgorithm.tooltip"));

    jlDigestAlgorithm = new JLabel(res.getString("DSignJar.jlDigestAlgorithm.text"));
    jcbDigestAlgorithm = new JComboBox<DigestType>();
    populateDigestAlgs();
    jcbDigestAlgorithm.setToolTipText(res.getString("DSignJar.jcbDigestAlgorithm.tooltip"));

    jlAddTimestamp = new JLabel(res.getString("DSignJar.jlAddTimestamp.text"));
    jcbAddTimestamp = new JCheckBox();
    jcbAddTimestamp.setSelected(false);
    jcbAddTimestamp.setToolTipText(res.getString("DSignJar.jcbAddTimestamp.tooltip"));

    jlTimestampServerUrl = new JLabel(res.getString("DSignJar.jlTimestampServerUrl.text"));
    jcbTimestampServerUrl = new JComboBox<String>();
    jcbTimestampServerUrl.setEditable(true);
    jcbTimestampServerUrl.setEnabled(false);
    jcbTimestampServerUrl.setToolTipText(res.getString("DSignJar.jcbTimestampServerUrl.tooltip"));
    jcbTimestampServerUrl.setModel(new DefaultComboBoxModel<String>(getTsaUrls()));

    jbOK = new JButton(res.getString("DSignJar.jbOK.text"));

    jbCancel = new JButton(res.getString("DSignJar.jbCancel.text"));
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);

    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel);

    // layout
    Container pane = getContentPane();
    pane.setLayout(new MigLayout("insets dialog, fill", "[para]unrel[right]unrel[]", "[]unrel[]"));
    MiGUtil.addSeparator(pane, res.getString("DSignJar.jlFiles.text"));
    pane.add(jlInputJar, "skip");
    pane.add(jtfInputJar, "sgx");
    pane.add(jbInputJarBrowse, "wrap");
    pane.add(jlSignDirectly, "skip");
    pane.add(jcbSignDirectly, "wrap");
    pane.add(jlOutputJar, "skip");
    pane.add(jtfOutputJar, "sgx");
    pane.add(jbOutputJarBrowse, "wrap para");
    MiGUtil.addSeparator(pane, res.getString("DSignJar.jlSignature.text"));
    pane.add(jlSignatureName, "skip");
    pane.add(jtfSignatureName, "sgx, wrap");
    pane.add(jlSignatureAlgorithm, "skip");
    pane.add(jcbSignatureAlgorithm, "sgx, wrap");
    pane.add(jlDigestAlgorithm, "skip");
    pane.add(jcbDigestAlgorithm, "sgx, wrap para");
    MiGUtil.addSeparator(pane, res.getString("DSignJar.jlTimestamp.text"));
    pane.add(jlAddTimestamp, "skip");
    pane.add(jcbAddTimestamp, "wrap");
    pane.add(jlTimestampServerUrl, "skip");
    pane.add(jcbTimestampServerUrl, "sgx, wrap para");
    pane.add(new JSeparator(), "spanx, growx, wrap para");
    pane.add(jpButtons, "right, spanx");

    // actions
    jbInputJarBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignJar.this);
                inputJarBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignJar.this);
            }
        }
    });

    jcbSignDirectly.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent evt) {
            jtfOutputJar.setEnabled(!jcbSignDirectly.isSelected());
            jbOutputJarBrowse.setEnabled(!jcbSignDirectly.isSelected());
        }
    });

    jbOutputJarBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignJar.this);
                outputJarBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignJar.this);
            }
        }
    });

    jcbAddTimestamp.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent evt) {
            jcbTimestampServerUrl.setEnabled(jcbAddTimestamp.isSelected());
        }
    });

    jbOK.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });

    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    setResizable(false);

    getRootPane().setDefaultButton(jbOK);

    pack();
    setLocationRelativeTo(null);
}

From source file:org.kse.gui.dialogs.sign.DSignMidlet.java

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;/*  ww w .jav a  2 s .  c  o m*/
    gbcLbl.gridwidth = 1;
    gbcLbl.gridheight = 1;
    gbcLbl.insets = new Insets(5, 5, 5, 5);
    gbcLbl.anchor = GridBagConstraints.EAST;
    gbcLbl.weightx = 0;

    GridBagConstraints gbcCtrl = new GridBagConstraints();
    gbcCtrl.gridx = 1;
    gbcCtrl.gridwidth = 1;
    gbcCtrl.gridheight = 1;
    gbcCtrl.insets = new Insets(5, 5, 5, 5);
    gbcCtrl.anchor = GridBagConstraints.WEST;
    gbcCtrl.fill = GridBagConstraints.NONE;
    gbcCtrl.weightx = 1;

    GridBagConstraints gbcBrws = new GridBagConstraints();
    gbcBrws.gridx = 2;
    gbcBrws.gridwidth = 1;
    gbcBrws.gridheight = 1;
    gbcBrws.insets = new Insets(5, 5, 5, 5);
    gbcBrws.anchor = GridBagConstraints.WEST;
    gbcBrws.fill = GridBagConstraints.NONE;
    gbcBrws.weightx = 1;

    jlInputJad = new JLabel(res.getString("DSignMidlet.jlInputJad.text"));
    GridBagConstraints gbc_jlInputJad = (GridBagConstraints) gbcLbl.clone();
    gbc_jlInputJad.gridy = 0;

    jtfInputJad = new JTextField(30);
    jtfInputJad.setCaretPosition(0);
    jtfInputJad.setToolTipText(res.getString("DSignMidlet.jtfInputJad.tooltip"));
    GridBagConstraints gbc_jtfInputJad = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfInputJad.gridy = 0;

    jbInputJadBrowse = new JButton(res.getString("DSignMidlet.jbInputJadBrowse.text"));
    PlatformUtil.setMnemonic(jbInputJadBrowse,
            res.getString("DSignMidlet.jbInputJadBrowse.mnemonic").charAt(0));
    jbInputJadBrowse.setToolTipText(res.getString("DSignMidlet.jbInputJadBrowse.tooltip"));
    jbInputJadBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignMidlet.this);
                inputJadBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignMidlet.this);
            }
        }
    });
    GridBagConstraints gbc_jbInputJadBrowse = (GridBagConstraints) gbcBrws.clone();
    gbc_jbInputJadBrowse.gridy = 0;

    jlSignDirectly = new JLabel(res.getString("DSignMidlet.jlSignDirectly.text"));
    GridBagConstraints gbc_jlSignDirectly = (GridBagConstraints) gbcLbl.clone();
    gbc_jlSignDirectly.gridy = 1;

    jcbSignDirectly = new JCheckBox();
    jcbSignDirectly.setSelected(true);
    jcbSignDirectly.setToolTipText(res.getString("DSignMidlet.jcbSignDirectly.tooltip"));
    GridBagConstraints gbc_jcbSignDirectly = (GridBagConstraints) gbcCtrl.clone();
    gbc_jcbSignDirectly.gridy = 1;

    jcbSignDirectly.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent evt) {
            jtfOutputJad.setEnabled(!jcbSignDirectly.isSelected());
            jbOutputJadBrowse.setEnabled(!jcbSignDirectly.isSelected());
        }
    });

    jlOutputJad = new JLabel(res.getString("DSignMidlet.jlOutputJad.text"));
    GridBagConstraints gbc_jlOutputJad = (GridBagConstraints) gbcLbl.clone();
    gbc_jlOutputJad.gridy = 2;

    jtfOutputJad = new JTextField(30);
    jtfOutputJad.setEnabled(false);
    jtfOutputJad.setCaretPosition(0);
    jtfOutputJad.setToolTipText(res.getString("DSignMidlet.jtfOutputJad.tooltip"));
    GridBagConstraints gbc_jtfOutputJad = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfOutputJad.gridy = 2;

    jbOutputJadBrowse = new JButton(res.getString("DSignMidlet.jbOutputJadBrowse.text"));
    PlatformUtil.setMnemonic(jbOutputJadBrowse,
            res.getString("DSignMidlet.jbOutputJadBrowse.mnemonic").charAt(0));
    jbOutputJadBrowse.setToolTipText(res.getString("DSignMidlet.jbOutputJadBrowse.tooltip"));
    jbOutputJadBrowse.setEnabled(false);
    jbOutputJadBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignMidlet.this);
                outputJadBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignMidlet.this);
            }
        }
    });
    GridBagConstraints gbc_jbOutputJadBrowse = (GridBagConstraints) gbcBrws.clone();
    gbc_jbOutputJadBrowse.gridy = 2;

    jlJar = new JLabel(res.getString("DSignMidlet.jlJar.text"));
    GridBagConstraints gbc_jlJar = (GridBagConstraints) gbcLbl.clone();
    gbc_jlJar.gridy = 3;

    jtfJar = new JTextField(30);
    jtfJar.setCaretPosition(0);
    jtfJar.setToolTipText(res.getString("DSignMidlet.jtfJar.tooltip"));
    GridBagConstraints gbc_jtfJar = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfJar.gridy = 3;

    jbJarBrowse = new JButton(res.getString("DSignMidlet.jbJarBrowse.text"));
    PlatformUtil.setMnemonic(jbJarBrowse, res.getString("DSignMidlet.jbJarBrowse.mnemonic").charAt(0));
    jbJarBrowse.setToolTipText(res.getString("DSignMidlet.jbJarBrowse.tooltip"));
    jbJarBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignMidlet.this);
                jarBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignMidlet.this);
            }
        }
    });
    GridBagConstraints gbc_jbJarBrowse = (GridBagConstraints) gbcBrws.clone();
    gbc_jbJarBrowse.gridy = 3;

    jpOptions = new JPanel(new GridBagLayout());
    jpOptions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()));

    jpOptions.add(jlInputJad, gbc_jlInputJad);
    jpOptions.add(jtfInputJad, gbc_jtfInputJad);
    jpOptions.add(jbInputJadBrowse, gbc_jbInputJadBrowse);
    jpOptions.add(jlSignDirectly, gbc_jlSignDirectly);
    jpOptions.add(jcbSignDirectly, gbc_jcbSignDirectly);
    jpOptions.add(jlOutputJad, gbc_jlOutputJad);
    jpOptions.add(jtfOutputJad, gbc_jtfOutputJad);
    jpOptions.add(jbOutputJadBrowse, gbc_jbOutputJadBrowse);
    jpOptions.add(jlJar, gbc_jlJar);
    jpOptions.add(jtfJar, gbc_jtfJar);
    jpOptions.add(jbJarBrowse, gbc_jbJarBrowse);

    jbOK = new JButton(res.getString("DSignMidlet.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });

    jbCancel = new JButton(res.getString("DSignMidlet.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(jpOptions, BorderLayout.NORTH);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    setResizable(false);

    getRootPane().setDefaultButton(jbOK);

    pack();
}

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

public boolean show(List<Rule> rules) {
    configChanged = false;//from w w w .j  a  v  a  2s  .c om
    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;
}