Exemplo n.º 1
0
public class PasswordDialog extends JDialog {
  private static final long serialVersionUID = 1L;
  JPanel panel = new JPanel();
  JPasswordField password = new JPasswordField(1);
  JLabel passLabel = new JLabel(I18N.getLocaleString("PASSWORD_PASSLABEL"));
  JButton submitButton = new JButton(I18N.getLocaleString("MAIN_SUBMIT"));

  public PasswordDialog(LaunchFrame instance, boolean modal) {
    super(instance, modal);

    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("PASSWORD_TITLE"));
    setBounds(300, 300, 300, 120);
    setResizable(false);

    getRootPane().setDefaultButton(submitButton);

    panel.setBounds(0, 0, 300, 100);
    setContentPane(panel);
    panel.setLayout(null);

    passLabel.setBounds(10, 10, 80, 30);
    passLabel.setVisible(true);
    panel.add(passLabel);

    password.setBounds(100, 10, 170, 30);
    password.setVisible(true);
    panel.add(password);

    submitButton.setBounds(105, 50, 90, 25);
    submitButton.setVisible(true);
    submitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (!new String(password.getPassword()).isEmpty()) {
              LaunchFrame.tempPass = new String(password.getPassword());
              setVisible(false);
            }
          }
        });
    panel.add(submitButton);
  }
}
Exemplo n.º 2
0
  public PasswordDialog(LaunchFrame instance, boolean modal) {
    super(instance, modal);

    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("PASSWORD_TITLE"));
    setBounds(300, 300, 300, 120);
    setResizable(false);

    getRootPane().setDefaultButton(submitButton);

    panel.setBounds(0, 0, 300, 100);
    setContentPane(panel);
    panel.setLayout(null);

    passLabel.setBounds(10, 10, 80, 30);
    passLabel.setVisible(true);
    panel.add(passLabel);

    password.setBounds(100, 10, 170, 30);
    password.setVisible(true);
    panel.add(password);

    submitButton.setBounds(105, 50, 90, 25);
    submitButton.setVisible(true);
    submitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (!new String(password.getPassword()).isEmpty()) {
              LaunchFrame.tempPass = new String(password.getPassword());
              setVisible(false);
            }
          }
        });
    panel.add(submitButton);
  }