Example usage for javax.swing AbstractAction AbstractAction

List of usage examples for javax.swing AbstractAction AbstractAction

Introduction

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

Prototype

public AbstractAction() 

Source Link

Document

Creates an Action .

Usage

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

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;/*from   w w  w.j  a  va2s . 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("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.importexport.DImportKeyPairPkcs8.java

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;//  ww  w  . j a v a 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("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.DImportKeyPairOpenSsl.java

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;/*from www.  ja v  a2  s  .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:nz.govt.natlib.ndha.manualdeposit.bulkupload.BulkUploadQueueManagement.java

private void checkJobQueue() {
    if (closeDownBulkUpload) {
        return;/*from ww  w  .jav  a2 s . c  o m*/
    }
    LOG.debug("Start checkJobQueue");
    int noOfJobsQueryingCMS = 0;
    int noOfJobsNotQueriedCMS = 0;
    int noOfJobsQueryingDPS = 0;
    int noOfJobsNotQueriedDPS = 0;
    int noOfJobsNotQueued = 0;
    int noOfJobsToBeBatched = 0;

    // System.out.println("Start checkJobQueue");
    synchronized (bulkUploadItems) {
        for (BulkUploadItem item : bulkUploadItems) {
            if ((item.getJobState() != JobState.Batching) && (item.getJobState() != JobState.IndigoJobCreated)
                    && (!item.getJobState().isError())) {
                noOfJobsToBeBatched++;
            }
            switch (item.getJobState()) {
            case Requested:
                noOfJobsNotQueriedCMS++;
                break;
            case QueryingCMS:
                noOfJobsQueryingCMS++;
                break;
            case CMSIDRetrieved:
                if (checkDPS) {
                    noOfJobsNotQueriedDPS++;
                } else {
                    noOfJobsNotQueued++;
                }
                break;
            case QueryingDPS:
                noOfJobsQueryingDPS++;
                break;
            case ItemDoesNotExistInDPS:
                if (!checkDPS) {
                    item.setJobState(JobState.CMSIDRetrieved);
                } else {
                    noOfJobsNotQueued++;
                }
                break;
            case ItemExistsInDPS:
                if (!checkDPS) {
                    item.setJobState(JobState.CMSIDRetrieved);
                }
                break;
            case Batching:
                if ((item.getUploadJobState() != null)
                        && (item.getUploadJobState() != UploadJob.JobState.Batching)) {
                    item.setJobState(JobState.IndigoJobCreated);
                }
                break;
            default:
                break;
            }
        }
        if (bulkUploadIsRunning && noOfJobsToBeBatched == 0 && !bulkUploadParent.isLoadingFiles()) {
            bulkUploadIsRunning = false;
        }
        if (noOfJobsNotQueriedCMS > 0
                && noOfJobsQueryingCMS < applicationProperties.getApplicationData().getBulkQueryCount()) {
            int noQuerying = 0;
            for (BulkUploadItem item : bulkUploadItems) {
                if (item.getJobState() == JobState.Requested) {
                    item.retrieveCMSDetails();
                    noQuerying++;
                    if (noQuerying + noOfJobsQueryingCMS >= applicationProperties.getApplicationData()
                            .getBulkQueryCount()) {
                        break;
                    }
                }
            }
        }
        if (checkDPS && noOfJobsNotQueriedDPS > 0
                && noOfJobsQueryingDPS < applicationProperties.getApplicationData().getBulkQueryCount()) {
            for (BulkUploadItem item : bulkUploadItems) {
                if (item.getJobState() == JobState.CMSIDRetrieved) {
                    item.checkDPS();
                }
            }
        }
        if (bulkUploadIsRunning && noOfJobsNotQueued > 0) {
            for (BulkUploadItem item : bulkUploadItems) {
                if (((item.getJobState() == JobState.CMSIDRetrieved) && (!checkDPS))
                        || (item.getJobState() == JobState.ItemDoesNotExistInDPS)) {
                    // System.out.println("Need to batch " + item.getCMSID()
                    // + ": " + item.getJobState().description());
                    if (uploadJob == null) {
                        try {
                            uploadJob = item.createJob();
                        } catch (Exception ex) {
                            LOG.error("Error creating job", ex);
                            // Should be safe to swallow this error as it
                            // would
                            // normally be handled before now.
                        }
                    } else {
                        // System.out.println("Add job " + item.getCMSID());
                        try {
                            item.addToJob(uploadJob);
                        } catch (JobQueueException jex) {
                            LOG.error("Error adding job", jex);
                            // Again, should be safe to swallow this error
                            // as it would
                            // normally be handled before now.
                        }
                    }
                    noOfJobsToBeBatched--;
                    if ((uploadJob.getJobDetail().size() >= userGroup.getBulkBatchSize())
                            || ((noOfJobsToBeBatched == 0) && (!bulkUploadParent.isLoadingFiles()))) {
                        uploadJob.prepareJobToRun();
                        theManualDepositParent.addJob(uploadJob);
                        uploadJob = null;
                    }
                }
            }
        }
    }
    if (theBulkUploadItemsTable != null) {
        theBulkUploadItemsTable.repaint();
    }
    bulkUploadParent.checkButtons();
    Action checkJobQueueAction = new AbstractAction() {
        private static final long serialVersionUID = 5562669711772031634L;

        public void actionPerformed(ActionEvent e) {
            Timer t = (Timer) e.getSource();
            t.stop();
            checkJobQueue();
        }
    };
    new Timer(applicationProperties.getApplicationData().getJobQueueRefreshInterval(), checkJobQueueAction)
            .start();
    LOG.debug("End checkJobQueue");
    // System.out.println("End checkJobQueue");
}

From source file:com.adobe.aem.demomachine.gui.AemDemoUtils.java

public static void installEscapeCloseOperation(final JDialog dialog) {
    Action dispatchClosing = new AbstractAction() {

        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent event) {
            dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
        }//from w  w  w .  ja  v  a2  s  .c  o  m
    };
    JRootPane root = dialog.getRootPane();
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, dispatchWindowClosingActionMapKey);
    root.getActionMap().put(dispatchWindowClosingActionMapKey, dispatchClosing);
}

From source file:com.vgi.mafscaling.Rescale.java

private void createMafScalesScrollPane(JPanel dataPanel) {
    JPanel mafPanel = new JPanel();
    GridBagLayout gbl_mafPanelLayout = new GridBagLayout();
    gbl_mafPanelLayout.columnWidths = new int[] { 0 };
    gbl_mafPanelLayout.rowHeights = new int[] { 0, 0 };
    gbl_mafPanelLayout.columnWeights = new double[] { 0.0, 1.0 };
    gbl_mafPanelLayout.rowWeights = new double[] { 0.0, 1.0 };
    mafPanel.setLayout(gbl_mafPanelLayout);

    JScrollPane mafScrollPane = new JScrollPane(mafPanel);
    mafScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    mafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    GridBagConstraints gbl_mafScrollPane = new GridBagConstraints();
    gbl_mafScrollPane.anchor = GridBagConstraints.PAGE_START;
    gbl_mafScrollPane.fill = GridBagConstraints.HORIZONTAL;
    gbl_mafScrollPane.insets = insets0;//www. j a v  a2 s  .  co m
    gbl_mafScrollPane.weightx = 1.0;
    gbl_mafScrollPane.gridx = 0;
    gbl_mafScrollPane.gridy = 1;
    gbl_mafScrollPane.ipady = 120;
    dataPanel.add(mafScrollPane, gbl_mafScrollPane);

    GridBagConstraints gbc_mafScrollPane = new GridBagConstraints();
    gbc_mafScrollPane.anchor = GridBagConstraints.PAGE_START;
    gbc_mafScrollPane.weightx = 1.0;
    gbc_mafScrollPane.weighty = 1.0;
    gbc_mafScrollPane.insets = insets0;
    gbc_mafScrollPane.fill = GridBagConstraints.HORIZONTAL;
    gbc_mafScrollPane.gridx = 0;
    gbc_mafScrollPane.gridy = 0;

    MafTablePane origMafScrollPane = new MafTablePane(ColumnWidth, OrigMafTableName, false, false);
    origMafScrollPane.setBorder(null);
    origMafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    origMafTable = origMafScrollPane.getJTable();
    excelAdapter.addTable(origMafTable, false, false, false, false, false, false, false, false, true);
    mafPanel.add(origMafScrollPane, gbc_mafScrollPane);

    MafTablePane newMafScrollPane = new MafTablePane(ColumnWidth, NewMafTableName, false, true);
    newMafScrollPane.setBorder(null);
    newMafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    newMafTable = newMafScrollPane.getJTable();
    newMafExcelAdapter.addTable(newMafTable, false, false, false, false, false, false, false, false, true);
    gbc_mafScrollPane.gridy++;
    mafPanel.add(newMafScrollPane, gbc_mafScrollPane);

    Action action = new AbstractAction() {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            recalculateNewGs();
        }
    };

    setNewMafTableCellListenerListener(new TableCellListener(newMafTable, action));
}

From source file:org.rdv.ui.ExportDialog.java

private void initComponents(List<String> channels, List<String> fileFormats) {
    channelModel = new DefaultListModel();

    for (int i = 0; i < channels.size(); i++) {
        String channelName = (String) channels.get(i);
        Channel channel = RBNBController.getInstance().getChannel(channelName);

        String mime = channel.getMetadata("mime");

        if (mime.equals("application/octet-stream")) {
            channelModel.addElement(new ExportChannel(channelName));
        }/*from w w w .j av  a  2s.c  o m*/
    }

    JPanel container = new JPanel();
    setContentPane(container);

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    JLabel headerLabel = new JLabel("Select the time range and data channels to export.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    JPanel timeButtonPanel = new JPanel();
    timeButtonPanel.setLayout(new BorderLayout());

    MouseListener hoverMouseListener = new MouseAdapter() {
        public void mouseEntered(MouseEvent e) {
            e.getComponent().setForeground(Color.red);
        }

        public void mouseExited(MouseEvent e) {
            e.getComponent().setForeground(Color.blue);
        }
    };

    startTimeButton = new JButton();
    startTimeButton.setBorder(null);
    startTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    startTimeButton.setForeground(Color.blue);
    startTimeButton.addMouseListener(hoverMouseListener);
    startTimeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            double startTime = DateTimeDialog.showDialog(ExportDialog.this, timeSlider.getStart(),
                    timeSlider.getMinimum(), timeSlider.getEnd());
            if (startTime >= 0) {
                timeSlider.setStart(startTime);
            }
        }
    });
    timeButtonPanel.add(startTimeButton, BorderLayout.WEST);

    durationLabel = new JLabel();
    durationLabel.setHorizontalAlignment(JLabel.CENTER);
    timeButtonPanel.add(durationLabel, BorderLayout.CENTER);

    endTimeButton = new JButton();
    endTimeButton.setBorder(null);
    endTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    endTimeButton.setForeground(Color.blue);
    endTimeButton.addMouseListener(hoverMouseListener);
    endTimeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            double endTime = DateTimeDialog.showDialog(ExportDialog.this, timeSlider.getEnd(),
                    timeSlider.getStart(), timeSlider.getMaximum());
            if (endTime >= 0) {
                timeSlider.setEnd(endTime);
            }
        }
    });
    timeButtonPanel.add(endTimeButton, BorderLayout.EAST);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(10, 10, 10, 10);
    container.add(timeButtonPanel, c);

    timeSlider = new TimeSlider();
    timeSlider.setValueChangeable(false);
    timeSlider.setValueVisible(false);
    timeSlider.addTimeAdjustmentListener(new TimeAdjustmentListener() {
        public void timeChanged(TimeEvent event) {
        }

        public void rangeChanged(TimeEvent event) {
            updateTimeRangeLabel();
        }

        public void boundsChanged(TimeEvent event) {
        }
    });
    updateTimeRangeLabel();
    updateTimeBounds();

    List<EventMarker> markers = RBNBController.getInstance().getMarkerManager().getMarkers();
    for (EventMarker marker : markers) {
        timeSlider.addMarker(marker);
    }

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(timeSlider, c);

    JLabel numericHeaderLabel = new JLabel("Data Channels:");
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(numericHeaderLabel, c);

    numericChannelList = new JList(channelModel);
    numericChannelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    numericChannelList.setCellRenderer(new CheckListRenderer());
    numericChannelList.setVisibleRowCount(10);
    numericChannelList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            int index = numericChannelList.locationToIndex(e.getPoint());
            ExportChannel item = (ExportChannel) numericChannelList.getModel().getElementAt(index);
            item.setSelected(!item.isSelected());
            Rectangle rect = numericChannelList.getCellBounds(index, index);
            numericChannelList.repaint(rect);

            checkSelectedChannels();

            updateTimeBounds();
        }
    });
    JScrollPane scrollPane = new JScrollPane(numericChannelList);
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0;
    c.weighty = 1;
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(scrollPane, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 10, 10, 5);
    container.add(new JLabel("Data file: "), c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    dataFileTextField = new JTextField(20);
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(dataFileTextField, c);

    dataFileTextField
            .setText(UIUtilities.getCurrentDirectory().getAbsolutePath() + File.separator + "data.dat");
    dataFileButton = new JButton("Browse");
    dataFileButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            File selectedFile = new File(dataFileTextField.getText());
            selectedFile = UIUtilities.getFile("OK", "Select export file", selectedFile);
            if (selectedFile != null) {
                dataFileTextField.setText(selectedFile.getAbsolutePath());
            }
        }
    });
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 2;
    c.gridy = 5;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 0, 10, 10);
    container.add(dataFileButton, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 10, 10, 5);
    container.add(new JLabel("File format: "), c);

    fileFormatComboBox = new JComboBox(fileFormats.toArray());
    fileFormatComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            fileFormatUpdated();
        }
    });
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(0, 0, 10, 10);
    container.add(fileFormatComboBox, c);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());

    Action exportAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -5356258138620428023L;

        public void actionPerformed(ActionEvent e) {
            ok();
        }
    };
    exportAction.putValue(Action.NAME, "Export");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "export");
    actionMap.put("export", exportAction);
    exportButton = new JButton(exportAction);
    panel.add(exportButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -5868609501314154642L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    panel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(panel, c);

    pack();
    if (getWidth() < 600) {
        setSize(600, getHeight());
    }

    dataFileTextField.requestFocusInWindow();

    setLocationByPlatform(true);
}

From source file:org.executequery.gui.editor.QueryEditor.java

private void addDeleteLineActionMapping() {

    Action action = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {

            deleteLine();/*from w w  w  . j  a v a  2s.c  o m*/
        }
    };

    KeyStroke keyStroke = KeyStroke.getKeyStroke("control D");

    ActionMap textPaneActionMap = editorPanel.getTextPaneActionMap();
    InputMap textPaneInputMap = editorPanel.getTextPaneInputMap();

    String actionMapKey = "editor-delete-line";

    textPaneActionMap.put(actionMapKey, action);
    textPaneInputMap.put(keyStroke, actionMapKey);
}

From source file:com.limegroup.gnutella.gui.GUIUtils.java

/**
 * Returns (possibly constructing) the ESC action.
 *//* ww w .  j a  v  a  2s .c om*/
public static Action getDisposeAction() {
    if (ACTION_DISPOSE == null) {
        ACTION_DISPOSE = new AbstractAction() {

            /**
             * 
             */
            private static final long serialVersionUID = 3219036624812939826L;

            public void actionPerformed(ActionEvent ae) {
                Window parent;
                if (ae.getSource() instanceof Window)
                    parent = (Window) ae.getSource();
                else
                    parent = SwingUtilities.getWindowAncestor((Component) ae.getSource());

                if (parent != null)
                    parent.dispatchEvent(new WindowEvent(parent, WindowEvent.WINDOW_CLOSING));
            }
        };
    }
    return ACTION_DISPOSE;
}

From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java

private JPanel getElementos() {
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    panel.setOpaque(false);//from w w  w  .  j a  v a 2s .co m
    panel.setBorder(new TitledBorder("Elementos a Consultar"));

    JLabel jLabel = new JLabel("Recursos", SwingConstants.RIGHT);
    jLabel.setPreferredSize(ConsultaHistoricos.DIMENSION_LABEL);
    panel.add(jLabel);
    recursos = new JList(new DefaultListModel());
    recursos.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), "selectAll");
    recursos.getActionMap().put("selectAll", new AbstractAction() {

        private static final long serialVersionUID = -5515338515763292526L;

        @Override
        public void actionPerformed(ActionEvent e) {
            recursos.setSelectionInterval(0, recursos.getModel().getSize() - 1);
        }
    });
    recursos.addListSelectionListener(listSelectionListener);
    final JScrollPane jScrollPaneR = new JScrollPane(recursos, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jScrollPaneR.getViewport().setPreferredSize(DIMENSION_JLIST);
    panel.add(jScrollPaneR);

    jLabel = new JLabel("Incidencias", SwingConstants.RIGHT);
    jLabel.setPreferredSize(ConsultaHistoricos.DIMENSION_LABEL);
    panel.add(jLabel);
    incidencias = new JList(new DefaultListModel());
    incidencias.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), "selectAll");
    incidencias.getActionMap().put("selectAll", new AbstractAction() {

        private static final long serialVersionUID = -5515338515763292526L;

        @Override
        public void actionPerformed(ActionEvent e) {
            incidencias.setSelectionInterval(0, incidencias.getModel().getSize() - 1);
        }
    });
    incidencias.addListSelectionListener(listSelectionListener);
    final JScrollPane jScrollPaneI = new JScrollPane(incidencias, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jScrollPaneI.getViewport().setPreferredSize(DIMENSION_JLIST);
    panel.setPreferredSize(DIMENSION_2JLIST);
    panel.add(jScrollPaneI);
    return panel;
}