if (!gainedFocusBefore) { gainedFocusBefore = true; passwordField.requestFocusInWindow();
@Override public void selectInitialValue() { passwordField.requestFocusInWindow(); } };
/** {@inheritDoc} */ @Override public void selectInitialValue() { pwd.requestFocusInWindow(); } };
@Override public void windowGainedFocus(WindowEvent e) { suPasswordField.requestFocusInWindow(); } });
@Override public void requestInitialFocus() { password1.requestFocusInWindow(); }
@Override public void requestInitialFocus() { password.requestFocusInWindow(); }
@Override public void windowOpened(WindowEvent e) { // Pack again to ensure the height is correct for the now-wrapped message area dialog.pack(); panel.passwordField.requestFocusInWindow(); } });
@Override public void windowOpened(WindowEvent e) { // Pack again to ensure the height is correct for the now-wrapped message area dialog.pack(); panel.passwordField.requestFocusInWindow(); } });
@Override public void addNotify() { super.addNotify(); passwordField.requestFocusInWindow(); }
private void setChangePasswordEnabled(final boolean enabled) { passwordLabel.setEnabled(enabled); passwordField.setEnabled(enabled); if (enabled) passwordField.requestFocusInWindow(); }
public void setFocusToFirstEmptyInputField() { if (jtextfieldUsername.getText().length() == 0) { jtextfieldUsername.requestFocusInWindow(); } else { jpasswordfieldPW.requestFocusInWindow(); } }
final JPasswordField pf = new JPasswordField(10); JOptionPane op = new JOptionPane(pf, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog d = op.createDialog("Test"); d.addWindowFocusListener(new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { pf.requestFocusInWindow(); } }); d.pack(); d.setLocationRelativeTo(null); d.setVisible(true);
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event dispatch thread. */ public static void createAndShowGUI() { JFrame frame = new JFrame("MyProxyLogon " + version); MyProxyLogonGUI gui = new MyProxyLogonGUI(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(gui); frame.pack(); gui.passwordField.requestFocusInWindow(); frame.setVisible(true); }
final JPasswordField pf = new JPasswordField(); //Create OptionPane & Dialog JOptionPane pane = new JOptionPane(pf, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = pane.createDialog("ENTER SUPERUSER PASSWORD"); //Add a listener to the dialog to request focus of Password Field dialog.addComponentListener(new ComponentListener(){ @Override public void componentShown(ComponentEvent e) { pf.requestFocusInWindow(); } @Override public void componentHidden(ComponentEvent e) {} @Override public void componentResized(ComponentEvent e) {} @Override public void componentMoved(ComponentEvent e) {} }); dialog.setVisible(true);
public static String getPassword(String title) { JPanel panel = new JPanel(); final JPasswordField passwordField = new JPasswordField(10); panel.add(new JLabel("Password")); panel.add(passwordField); JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) { @Override public void selectInitialValue() { passwordField.requestFocusInWindow(); } }; pane.createDialog(null, title).setVisible(true); return passwordField.getPassword().length == 0 ? null : new String(passwordField.getPassword()); }
public void setFocusToFirstEmptyInputField() { if (jtextfieldServer.getText().length() == 0) { jtextfieldServer.requestFocusInWindow(); } else if (jtextfieldPort.getText().length() == 0) { jtextfieldPort.requestFocusInWindow(); } else if (jtextfieldManagerUsername.getText().length() == 0) { jtextfieldManagerUsername.requestFocusInWindow(); } else { jpasswordfieldManager.requestFocusInWindow(); } }
private void addInputArea() { labelPanel.setLayout(new GridLayout(3, 1)); Border labelsPadding = BorderFactory.createEmptyBorder(0, 0, 15, 0); labelPanel.setBorder(labelsPadding); deviceLabel = new JLabel(AgentConstants.APP_PUBLIC_NAME.toUpperCase()); Icon icon = new ImageIcon(TrayProcess.createImage(AgentConstants.ICON24_PATH, AgentConstants.ICON_DESCRIPTION)); deviceLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); deviceLabel.setIcon(icon); deviceLabel.setIconTextGap(10); deviceLabel.setFont(new Font(null, Font.BOLD, 15)); passcodeLabel = new JLabel(LocalizedLogger.getLocalizedMessage("DIALOG_ENTER_PASSPHRASE")); passcodeField = new JPasswordField(); passcodeField.requestFocusInWindow(); passcodeField.setBackground(Color.white); labelPanel.add(deviceLabel, BorderLayout.NORTH); labelPanel.add(passcodeLabel, BorderLayout.CENTER); labelPanel.add(passcodeField, BorderLayout.SOUTH); }
final JPasswordField jpf = new JPasswordField(); JOptionPane jop = new JOptionPane(jpf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = jop.createDialog("Password:"); dialog.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jpf.requestFocusInWindow(); } }); } }); dialog.setVisible(true); int result = (Integer) jop.getValue(); dialog.dispose(); char[] password = null; if (result == JOptionPane.OK_OPTION) { password = jpf.getPassword(); } if (password != null) System.out.println("your password: " + new String(password));
final JPasswordField jpf = new JPasswordField(); JOptionPane jop = new JOptionPane(jpf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = jop.createDialog("Password:"); dialog.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jpf.requestFocusInWindow(); } }); } }); dialog.setVisible(true); int result = (Integer) jop.getValue(); dialog.dispose(); char[] password = null; if (result == JOptionPane.OK_OPTION) { password = jpf.getPassword(); } if (password != null) System.out.println("your password: " + new String(password));
private String askPassphrase(String prompt) { GITUserPassDialog userPassDialog = new GITUserPassDialog(Core.getMainWindow().getApplicationFrame()); userPassDialog.setLocationRelativeTo(Core.getMainWindow().getApplicationFrame()); userPassDialog.descriptionTextArea.setText(prompt); userPassDialog.userText.setVisible(false); userPassDialog.userLabel.setVisible(false); userPassDialog.passwordField.requestFocusInWindow(); userPassDialog.setVisible(true); if (userPassDialog.getReturnStatus() == GITUserPassDialog.RET_OK) { return new String(userPassDialog.passwordField.getPassword()); } else { return null; } }