Search in sources :

Example 76 with JPasswordField

use of javax.swing.JPasswordField in project CodenameOne by codenameone.

the class EditableResources method checkKey.

void checkKey(String id) {
    JPasswordField password = new JPasswordField();
    if (currentPassword != null) {
        password.setText(currentPassword);
    }
    int v = JOptionPane.showConfirmDialog(java.awt.Frame.getFrames()[0], password, "Enter Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (v == JOptionPane.OK_OPTION) {
        currentPassword = password.getText();
        setPassword(currentPassword);
        try {
            key = currentPassword.getBytes("UTF-8");
        } catch (UnsupportedEncodingException ex) {
            ex.printStackTrace();
        }
        char l = (char) encode(id.charAt(0));
        char w = (char) encode(id.charAt(1));
        // keyOffset = 0;
        if (l != 'l' || w != 'w') {
            // incorrect password!
            JOptionPane.showMessageDialog(java.awt.Frame.getFrames()[0], "Incorrect Password!", "Error", JOptionPane.ERROR_MESSAGE);
            throw new IllegalStateException("Incorrect password");
        }
        return;
    }
    super.checkKey(id);
}
Also used : JPasswordField(javax.swing.JPasswordField) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 77 with JPasswordField

use of javax.swing.JPasswordField in project keystore-explorer by kaikramer.

the class DImportKeyPairOpenSsl method initComponents.

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;
    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, false);
    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();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) ItemEvent(java.awt.event.ItemEvent) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) EtchedBorder(javax.swing.border.EtchedBorder) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField) WindowEvent(java.awt.event.WindowEvent) CompoundBorder(javax.swing.border.CompoundBorder) ItemListener(java.awt.event.ItemListener) EmptyBorder(javax.swing.border.EmptyBorder) AbstractAction(javax.swing.AbstractAction)

Example 78 with JPasswordField

use of javax.swing.JPasswordField in project keystore-explorer by kaikramer.

the class DImportKeyPairPkcs8 method initComponents.

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;
    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, false);
    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();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) ItemEvent(java.awt.event.ItemEvent) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) EtchedBorder(javax.swing.border.EtchedBorder) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField) WindowEvent(java.awt.event.WindowEvent) CompoundBorder(javax.swing.border.CompoundBorder) ItemListener(java.awt.event.ItemListener) EmptyBorder(javax.swing.border.EmptyBorder) AbstractAction(javax.swing.AbstractAction)

Example 79 with JPasswordField

use of javax.swing.JPasswordField in project keystore-explorer by kaikramer.

the class DChangePassword method checkPassword.

private boolean checkPassword() {
    Password oldPassword = new Password(jpfOld.getPassword());
    Password firstPassword;
    if (jpfFirst instanceof JPasswordQualityField) {
        char[] firstPasswordChars = ((JPasswordQualityField) jpfFirst).getPassword();
        if (firstPasswordChars == null) {
            JOptionPane.showMessageDialog(this, res.getString("MinimumPasswordQualityNotMet.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
            return false;
        }
        firstPassword = new Password(firstPasswordChars);
    } else {
        firstPassword = new Password(((JPasswordField) jpfFirst).getPassword());
    }
    Password confirmPassword = new Password(jpfConfirm.getPassword());
    if (firstPassword.equals(confirmPassword)) {
        this.oldPassword = oldPassword;
        newPassword = firstPassword;
        return true;
    }
    JOptionPane.showMessageDialog(this, res.getString("PasswordsNoMatch.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
    return false;
}
Also used : JPasswordField(javax.swing.JPasswordField) Password(org.kse.crypto.Password)

Example 80 with JPasswordField

use of javax.swing.JPasswordField in project keystore-explorer by kaikramer.

the class DGetNewPassword method checkPassword.

private boolean checkPassword() {
    Password firstPassword;
    if (jpfFirst instanceof JPasswordQualityField) {
        char[] firstPasswordChars = ((JPasswordQualityField) jpfFirst).getPassword();
        if (firstPasswordChars == null) {
            JOptionPane.showMessageDialog(this, res.getString("MinimumPasswordQualityNotMet.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
            return false;
        }
        firstPassword = new Password(firstPasswordChars);
    } else {
        firstPassword = new Password(((JPasswordField) jpfFirst).getPassword());
    }
    Password confirmPassword = new Password(jpfConfirm.getPassword());
    if (firstPassword.equals(confirmPassword)) {
        password = firstPassword;
        return true;
    }
    JOptionPane.showMessageDialog(this, res.getString("PasswordsNoMatch.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
    return false;
}
Also used : JPasswordField(javax.swing.JPasswordField) Password(org.kse.crypto.Password)

Aggregations

JPasswordField (javax.swing.JPasswordField)100 JLabel (javax.swing.JLabel)60 JPanel (javax.swing.JPanel)47 JTextField (javax.swing.JTextField)44 BorderLayout (java.awt.BorderLayout)30 JButton (javax.swing.JButton)24 JCheckBox (javax.swing.JCheckBox)23 GridBagLayout (java.awt.GridBagLayout)22 GridBagConstraints (java.awt.GridBagConstraints)19 ActionEvent (java.awt.event.ActionEvent)19 ActionListener (java.awt.event.ActionListener)19 Insets (java.awt.Insets)18 Dimension (java.awt.Dimension)15 WindowAdapter (java.awt.event.WindowAdapter)12 WindowEvent (java.awt.event.WindowEvent)12 EmptyBorder (javax.swing.border.EmptyBorder)12 EtchedBorder (javax.swing.border.EtchedBorder)12 AbstractAction (javax.swing.AbstractAction)11 CompoundBorder (javax.swing.border.CompoundBorder)11 ItemEvent (java.awt.event.ItemEvent)7