Example usage for javax.swing JPasswordField JPasswordField

List of usage examples for javax.swing JPasswordField JPasswordField

Introduction

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

Prototype

public JPasswordField() 

Source Link

Document

Constructs a new JPasswordField, with a default document, null starting text string, and 0 column width.

Usage

From source file:edu.harvard.mcz.imagecapture.ChangePasswordDialog.java

/**
 * This method initializes jPasswordField1   
 *    //from   www  . j a  va 2  s  .c  o  m
 * @return javax.swing.JPasswordField   
 */
private JPasswordField getJPasswordField1() {
    if (jPasswordField1 == null) {
        jPasswordField1 = new JPasswordField();
    }
    return jPasswordField1;
}

From source file:edu.harvard.mcz.imagecapture.ChangePasswordDialog.java

/**
 * This method initializes jPasswordField2   
 *    /*w  w  w . ja va  2  s. c  o  m*/
 * @return javax.swing.JPasswordField   
 */
private JPasswordField getJPasswordField2() {
    if (jPasswordField2 == null) {
        jPasswordField2 = new JPasswordField();
    }
    return jPasswordField2;
}

From source file:com.supermap.desktop.icloud.CloudLicenseDialog.java

private void initComponents() {
    this.panelCloudImage = new JPanel();
    this.panelUserImage = new JPanel();
    this.labelWarning = new JLabel("");
    this.labelUserName = new JLabel();
    this.labelPassWord = new JLabel();
    this.textFieldUserName = new JTextField();
    this.fieldPassWord = new JPasswordField();
    this.labelRegister = new JLabel();
    this.labelFindPassword = new JLabel();
    this.checkBoxSavePassword = new JCheckBox();
    this.checkBoxAutoLogin = new JCheckBox();
    this.buttonLogin = new JButton();
    this.buttonClose = new JButton();
    initToken();/*from w ww.j a  v a  2  s  .c o m*/
    this.checkBoxAutoLogin.setVisible(false);
}

From source file:es.mityc.firmaJava.libreria.pkcs7.ValidaTarjeta.java

/**
 * This method initializes jPinPasswordField   
 *    // w w  w  .j  a  va2 s.c om
 * @return javax.swing.JPasswordField   
 */
private JPasswordField getJPinPasswordField() {
    if (jPinPasswordField == null) {
        jPinPasswordField = new JPasswordField();
        jPinPasswordField.setPreferredSize(new Dimension(150, 20));
        jPinPasswordField.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == 10) {
                    administrarTarjeta();
                }
            }
        });
    }
    return jPinPasswordField;
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

public JPasswordField appendPasswordField(String label, String tooltip) {
    JPasswordField textField = new JPasswordField();
    textField.setColumns(defaultTextFieldColumns);
    textField.setToolTipText(StringUtils.defaultIfEmpty(tooltip, null));
    textField.getAccessibleContext().setAccessibleDescription(tooltip);
    append(label, textField);//from w  w  w .j a va2s  . co  m
    return textField;
}

From source file:edu.harvard.mcz.imagecapture.LoginDialog.java

/**
 * This method initializes jPasswordFieldUser   
 *    //from   w  w  w.j av a 2s  .  c o  m
 * @return javax.swing.JPasswordField   
 */
private JPasswordField getJPasswordFieldUser() {
    if (jPasswordFieldUser == null) {
        jPasswordFieldUser = new JPasswordField();
    }
    return jPasswordFieldUser;
}

From source file:gov.nih.nci.nbia.StandaloneDMDispatcher.java

private void install(String downloadUrl) {
    Double vNum = 0.0;//from  www  .ja  v  a2  s . c o m
    if (appVersion != null) {
        vNum = Double.parseDouble(appVersion);
    }
    String installerPath = getInstallerName(downloadUrl);
    if (os.contains("windows")) {
        try {
            Runtime.getRuntime().exec("msiexec /i \"" + installerPath + "\"");
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (os.startsWith("mac")) {
        try {
            Runtime.getRuntime().exec(new String[] { "/usr/bin/open", installerPath });
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        JLabel pwLabel = new JLabel("Sudo Password");
        JTextField password = new JPasswordField();
        Object[] objs = { pwLabel, password };
        int result = JOptionPane.showConfirmDialog(null, objs, "Please enter a sudo password",
                JOptionPane.OK_CANCEL_OPTION);
        String pas = null;
        if (result == JOptionPane.OK_OPTION) {
            pas = password.getText();
        }

        if (pas != null) {
            if (os.equals("CentOS")) {
                // sudo yum install TCIADownloader-1.0-1.x86_64.rpm
                try {
                    String upgradCmd = "/usr/bin/sudo -S yum -q -y remove TCIADownloader.x86_64;/usr/bin/sudo -S yum -y -q install ";
                    if (vNum >= 3.2)
                        upgradCmd = "/usr/bin/sudo -S yum -q -y remove NBIADataRetriever.x86_64;/usr/bin/sudo -S yum -y -q install ";

                    String[] cmd = { "/bin/bash", "-c", upgradCmd + installerPath };

                    Process pb = Runtime.getRuntime().exec(cmd);
                    BufferedWriter writer = null;
                    writer = new BufferedWriter(new OutputStreamWriter(pb.getOutputStream()));
                    writer.write(pas);
                    writer.write('\n');
                    writer.flush();

                    String status = null;

                    if (pb.waitFor() == 0) {
                        status = "successfully";
                    } else {
                        status = "unsuccessfully";
                    }

                    JOptionPane.showMessageDialog(null,
                            "Installation of new version of NBIA Data Retriever is completed " + status + ".");
                } catch (IOException | InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } else if (os.equals("Ubuntu")) {
                // sudo dpkg -i tciadownloader_1.0-2_amd64.deb
                String upgradCmd = "/usr/bin/sudo -S dpkg -i ";
                if (vNum >= 3.2)
                    upgradCmd = "/usr/bin/sudo -S dpkg -i nbia-data-retriever; /usr/bin/sudo -S dpkg -i ";
                try {
                    String[] cmd = { "/bin/bash", "-c", upgradCmd + installerPath };

                    Process pb = Runtime.getRuntime().exec(cmd);
                    BufferedWriter writer = null;
                    writer = new BufferedWriter(new OutputStreamWriter(pb.getOutputStream()));
                    writer.write(pas);
                    writer.write('\n');
                    writer.flush();

                    String status = null;

                    if (pb.waitFor() == 0) {
                        status = "successfully";
                    } else {
                        status = "unsuccessfully";
                    }

                    JOptionPane.showMessageDialog(null,
                            "Installation of new version of NBIA Data Retriever is completed " + status + ".");
                } catch (IOException | InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:de.mycrobase.jcloudapp.Main.java

private static Map<String, String> showLoginDialog() {
    String message = ""; //"Welcome to JCloudApp!";

    JTextField usernameField = new JTextField();
    JPasswordField passwordField = new JPasswordField();
    JCheckBox remeberCheck = new JCheckBox("Remember login (on disk)");
    remeberCheck.setSelected(true);//from   w  ww .ja v  a  2 s. c o m
    Object[] content = { message, "Username:", usernameField, "Password:", passwordField, remeberCheck };

    //        int res = JOptionPane.showOptionDialog(
    //            null, content, "JCloudApp - Login",
    //            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, icon,
    //            null, usernameField);
    int res = JOptionPane.showConfirmDialog(null, content, "JCloudApp - Login", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE, IconLarge);

    if (res == JOptionPane.OK_OPTION) {
        HashMap<String, String> m = new HashMap<String, String>();
        m.put("username", usernameField.getText());
        m.put("password", new String(passwordField.getPassword()));
        m.put("remember", Boolean.toString(remeberCheck.isSelected()));
        return m;
    } else {
        return null;
    }
}

From source file:gov.nih.nci.nbia.StandaloneDMV3.java

private JPanel constructLoginPanel() {
    JPanel contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(36, 36, 36, 36));
    contentPane.setLayout(null);/*from w  ww .j  a v a 2  s  .  c o  m*/

    JPanel guestPanel = new JPanel();
    guestPanel.setBounds(38, 40, 825, 140);
    guestPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.RAISED, new Color(153, 180, 209), null),
            "  For Guest  ", TitledBorder.CENTER, TitledBorder.TOP, null, new Color(0, 120, 215)));
    contentPane.add(guestPanel);
    guestPanel.setLayout(null);

    JButton guestBtn = new JButton(GuestBtnLbl);
    guestBtn.setBounds(606, 50, 140, 36);
    guestBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            submitRequest(null, null);
        }
    });
    guestPanel.add(guestBtn);

    JLabel guestLbl = new JLabel("Log in as a guest to download public data only");
    guestLbl.setBounds(70, 50, 460, 42);
    guestPanel.add(guestLbl);

    JPanel loginUserPanel = new JPanel();
    loginUserPanel.setBounds(40, 258, 825, 306);
    contentPane.add(loginUserPanel);
    loginUserPanel
            .setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(153, 180, 209), null),
                    "  Login to Download Authorized Data  ", TitledBorder.CENTER, TitledBorder.TOP, null,
                    new Color(0, 120, 215)));
    loginUserPanel.setLayout(null);

    JLabel lblNewLabel_1 = new JLabel("User Name");
    lblNewLabel_1.setBounds(70, 80, 118, 36);
    loginUserPanel.add(lblNewLabel_1);

    JButton submitBtn = new JButton(SubmitBtnLbl);
    submitBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            userId = userNameFld.getText();
            password = passwdFld.getText();
            if ((userId.length() < 1) || (password.length() < 1)) {
                statusLbl.setText("Please enter a valid user name and password.");
                statusLbl.setForeground(Color.red);
            } else {
                submitRequest(userId, password);
            }
        }
    });
    submitBtn.setBounds(606, 238, 140, 36);
    loginUserPanel.add(submitBtn);

    userNameFld = new JTextField();
    userNameFld.setBounds(200, 80, 333, 36);
    loginUserPanel.add(userNameFld);
    userNameFld.setColumns(10);

    JLabel lblPassword = new JLabel("Password");
    lblPassword.setBounds(70, 156, 118, 36);
    loginUserPanel.add(lblPassword);

    passwdFld = new JPasswordField();
    passwdFld.setBounds(200, 156, 333, 36);
    loginUserPanel.add(passwdFld);

    statusLbl = new JLabel("");
    statusLbl.setBounds(70, 226, 463, 36);
    loginUserPanel.add(statusLbl);

    JLabel lblOr = new JLabel("--- OR ---");
    lblOr.setBounds(419, 212, 81, 26);
    contentPane.add(lblOr);

    JLabel versionLabel = new JLabel("Release " + DownloaderProperties.getAppVersion() + " Build \""
            + DownloaderProperties.getBuildTime() + "\"");
    versionLabel.setHorizontalAlignment(SwingConstants.CENTER);
    versionLabel.setForeground(new Color(70, 130, 180));
    versionLabel.setBounds(315, 584, 260, 20);
    contentPane.add(versionLabel);

    userNameFld.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            passwdFld.requestFocus();
        }
    });

    userNameFld.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            statusLbl.setText("");
        }

        @Override
        public void focusLost(FocusEvent e) {
        }
    });

    passwdFld.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            userId = userNameFld.getText();
            password = passwdFld.getText();
            if ((userId.length() < 1) || (password.length() < 1)) {
                statusLbl.setText("Please enter a valid user name and password.");
                statusLbl.setForeground(Color.red);
            } else
                submitRequest(userId, password);
        }
    });

    passwdFld.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            statusLbl.setText("");
        }

        @Override
        public void focusLost(FocusEvent e) {
        }
    });

    return contentPane;
}

From source file:net.java.sip.communicator.gui.AuthenticationSplash.java

/**
 * The user has selected an option. Here we close and dispose the dialog.
 * If actionCommand is an ActionEvent, getCommandString() is called,
 * otherwise toString() is used to get the action command.
 *
 * @param actionCommand may be null/* w w w . j a  v a  2s .  c om*/
 */
private void registrationComponents() {
    Container contents = getContentPane();
    contents.setLayout(new BorderLayout());

    String title = Utils.getProperty("net.java.sip.communicator.gui.REG_WIN_TITLE");

    if (title == null)
        title = "Registration Manager";

    setTitle(title);
    setResizable(false);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            registrationDialogDone(CMD_CANCEL);
        }
    });

    // Accessibility -- all frames, dialogs, and applets should
    // have a description
    getAccessibleContext().setAccessibleDescription("Registration Splash");

    String authPromptLabelValue = Utils.getProperty("net.java.sip.communicator.gui.REGISTRATION_PROMPT");

    if (authPromptLabelValue == null)
        authPromptLabelValue = "Please fill in the following fields to register:";

    JLabel splashLabel = new JLabel(authPromptLabelValue);
    splashLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    splashLabel.setHorizontalAlignment(SwingConstants.CENTER);
    splashLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    contents.add(splashLabel, BorderLayout.NORTH);

    JPanel centerPane = new JPanel();
    centerPane.setLayout(new GridBagLayout());

    /* My additions */
    nameTextField = new JTextField(); //needed below

    // name label
    nameLabel = new JLabel();
    nameLabel.setLabelFor(nameTextField);
    String nLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.NAME_LABEL");

    if (nLabelStr == null)
        nLabelStr = "Name";

    nameLabel.setText(nLabelStr);

    int gridy = 0;
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);

    centerPane.add(nameLabel, c);

    // name text
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(nameTextField, c);

    lastNameTextField = new JTextField(); //needed below

    // last name label
    lastNameLabel = new JLabel();
    lastNameLabel.setLabelFor(nameTextField);
    String lnLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.LAST_NAME_LABEL");

    if (lnLabelStr == null)
        lnLabelStr = "Last Name";

    lastNameLabel.setText(lnLabelStr);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);

    centerPane.add(lastNameLabel, c);

    // last name text
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(lastNameTextField, c);

    mailTextField = new JTextField(); //needed below

    // mail label
    mailLabel = new JLabel();
    mailLabel.setLabelFor(mailTextField);
    String mLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.MAIL_LABEL");

    if (mLabelStr == null)
        mLabelStr = "Email";

    mailLabel.setText(mLabelStr);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);

    centerPane.add(mailLabel, c);

    // mail text
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(mailTextField, c);
    /* END: MY additions */

    userNameTextField = new JTextField(); // needed below

    // user name label
    userNameLabel = new JLabel();
    userNameLabel.setLabelFor(userNameTextField);
    String userNameLabelValue = Utils.getProperty("net.java.sip.communicator.gui.USER_NAME_LABEL");

    if (userNameLabelValue == null)
        userNameLabelValue = "Username";

    userNameLabel.setText(userNameLabelValue);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(12, 12, 0, 0);
    centerPane.add(userNameLabel, c);

    // user name text
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(12, 7, 0, 11);
    centerPane.add(userNameTextField, c);

    passwordTextField = new JPasswordField(); //needed below

    // password label
    passwordLabel = new JLabel();
    passwordLabel.setLabelFor(passwordTextField);
    String pLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.PASSWORD_LABEL");

    if (pLabelStr == null)
        pLabelStr = "Password";

    passwordLabel.setText(pLabelStr);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);

    centerPane.add(passwordLabel, c);

    // password text
    passwordTextField.setEchoChar('\u2022');
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(passwordTextField, c);

    policyDropDown = new JComboBox();
    policyDropDown.addItem("Basic");
    policyDropDown.addItem("Pro");
    policyDropDown.addItem("Enterprise");

    // policy label
    policyLabel = new JLabel();
    policyLabel.setLabelFor(policyDropDown);
    String plcLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.POLICY_LABEL");

    if (plcLabelStr == null)
        plcLabelStr = "Policy";

    policyLabel.setText(plcLabelStr);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);
    centerPane.add(policyLabel, c);

    // policy menu
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(policyDropDown, c);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, 0));

    registerButton = new JButton();
    registerButton.setMnemonic('G');
    registerButton.setText("Register");
    registerButton.setActionCommand(CMD_REGISTER);
    registerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            registrationDialogDone(event);
        }
    });
    buttonPanel.add(registerButton);

    buttonPanel.add(Box.createRigidArea(new Dimension(5, 0)));

    cancelButton = new JButton();
    cancelButton.setText("Cancel");
    cancelButton.setActionCommand(CMD_CANCEL);
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            registrationDialogDone(event);
        }
    });
    buttonPanel.add(cancelButton);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.insets = new Insets(11, 12, 11, 11);

    centerPane.add(buttonPanel, c);

    contents.add(centerPane, BorderLayout.CENTER);
    getRootPane().setDefaultButton(registerButton);
    registrationEqualizeButtonSizes();

    setFocusTraversalPolicy(new FocusTraversalPol());

}