@SuppressWarnings("static-access")
  public DatePicker(Observer observer, Date selecteddate, Locale locale) {
    super();
    this.locale = locale;
    register(observer);
    screen = new JDialog();
    screen.addWindowFocusListener(this);
    screen.setSize(200, 200);
    screen.setResizable(false);
    screen.setModal(true);
    screen.setUndecorated(true);
    screen.setDefaultLookAndFeelDecorated(true);
    screen.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    screen.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    screen.getContentPane().setLayout(new BorderLayout());
    //
    calendar = new GregorianCalendar();
    setSelectedDate(selecteddate);
    Calendar c = calendar;
    if (selectedDate != null) c = selectedDate;
    updateScreen(c);
    screen.getContentPane().add(navPanel, BorderLayout.NORTH);

    screen.setTitle(getString("program.title", "Date Picker"));
  }
  void showPasswordDialog(boolean wasWrong) {
    WebPanel passPanel = new WebPanel();
    WebLabel passLabel = new WebLabel(Tr.tr("Please enter your key password:"******"Wrong password"));
      wrongLabel.setForeground(Color.RED);
      passPanel.add(wrongLabel, BorderLayout.SOUTH);
    }
    WebOptionPane passPane =
        new WebOptionPane(
            passPanel, WebOptionPane.QUESTION_MESSAGE, WebOptionPane.OK_CANCEL_OPTION);
    JDialog dialog = passPane.createDialog(mMainFrame, Tr.tr("Enter password"));
    dialog.setModal(true);
    dialog.addWindowFocusListener(
        new WindowAdapter() {
          @Override
          public void windowGainedFocus(WindowEvent e) {
            passField.requestFocusInWindow();
          }
        });
    // blocking
    dialog.setVisible(true);

    Object value = passPane.getValue();
    if (value != null && value.equals(WebOptionPane.OK_OPTION))
      mControl.connect(passField.getPassword());
  }
Exemple #3
0
  private String showPasswordDialog(String message) {
    final JPasswordField jpf = new JPasswordField();
    JOptionPane jop =
        new JOptionPane(jpf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    JDialog dialog = jop.createDialog(message);
    dialog.addWindowFocusListener(
        new WindowAdapter() {
          public void windowGainedFocus(WindowEvent e) {
            jpf.requestFocusInWindow();
          }
        });

    dialog.setVisible(true);
    int result = (Integer) jop.getValue();
    dialog.dispose();
    char[] password = null;
    if (result == JOptionPane.OK_OPTION) {
      password = jpf.getPassword();
    }
    return new String(password);
  }