예제 #1
0
 public void init(String username, String password) {
   username = username == null ? "" : username;
   password = password == null ? "" : password;
   tfUserName.setText(username);
   tfPassword.setText(password);
   cbSaveCredentials.setSelected(!username.isEmpty() && !password.isEmpty());
 }
예제 #2
0
 public char[] getPassword() {
   return tfPassword.getPassword();
 }
예제 #3
0
    protected void build() {
      tfUserName = new JosmTextField(20);
      tfPassword = new JosmPasswordField(20);
      tfUserName.addFocusListener(new SelectAllOnFocusHandler());
      tfPassword.addFocusListener(new SelectAllOnFocusHandler());
      tfUserName.addKeyListener(new TFKeyListener(owner, tfUserName, tfPassword));
      tfPassword.addKeyListener(new TFKeyListener(owner, tfPassword, tfUserName));
      cbSaveCredentials =
          new JCheckBox(owner != null ? owner.saveUsernameAndPasswordCheckboxText : "");

      setLayout(new GridBagLayout());
      GridBagConstraints gc = new GridBagConstraints();
      gc.gridwidth = 2;
      gc.gridheight = 1;
      gc.fill = GridBagConstraints.HORIZONTAL;
      gc.weightx = 1.0;
      gc.weighty = 0.0;
      gc.insets = new Insets(0, 0, 10, 0);
      add(lblHeading, gc);

      gc.gridx = 0;
      gc.gridy = 1;
      gc.gridwidth = 1;
      gc.gridheight = 1;
      gc.fill = GridBagConstraints.HORIZONTAL;
      gc.weightx = 0.0;
      gc.weighty = 0.0;
      gc.insets = new Insets(0, 0, 10, 10);
      add(new JLabel(tr("Username")), gc);
      gc.gridx = 1;
      gc.gridy = 1;
      gc.weightx = 1.0;
      add(tfUserName, gc);
      gc.gridx = 0;
      gc.gridy = 2;
      gc.weightx = 0.0;
      add(new JLabel(tr("Password")), gc);

      gc.gridx = 1;
      gc.gridy = 2;
      gc.weightx = 0.0;
      add(tfPassword, gc);

      gc.gridx = 0;
      gc.gridy = 3;
      gc.gridwidth = 2;
      gc.gridheight = 1;
      gc.fill = GridBagConstraints.BOTH;
      gc.weightx = 1.0;
      gc.weighty = 0.0;
      lblWarning.setFont(lblWarning.getFont().deriveFont(Font.ITALIC));
      add(lblWarning, gc);

      gc.gridx = 0;
      gc.gridy = 4;
      gc.weighty = 0.0;
      add(cbSaveCredentials, gc);

      // consume the remaining space
      gc.gridx = 0;
      gc.gridy = 5;
      gc.weighty = 1.0;
      add(new JPanel(), gc);
    }