@Override protected JTextComponent createField() { JPasswordField field = new JPasswordField(); field.putClientProperty("JComponent.sizeVariant", "small"); field.setFont(Theme.SMALL_BOLD_FONT); field.addActionListener(this); field.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { commitTextFieldValue(); } }); return field; }
txtPasswordField.addActionListener(evt -> txtPasswordFieldActionPerformed(evt));
/** * Creates new form ConnectDialog */ public ConnectDialog() { initComponents(); this.txtServer.addActionListener(connectAction); this.txtPort.addActionListener(connectAction); this.txtUserName.addActionListener(connectAction); this.txtPassword.addActionListener(connectAction); registerUserDialog = new RegisterUserDialog(this); MageFrame.getDesktop().add(registerUserDialog, JLayeredPane.MODAL_LAYER); resetPasswordDialog = new ResetPasswordDialog(this); MageFrame.getDesktop().add(resetPasswordDialog, JLayeredPane.MODAL_LAYER); }
private JPasswordField getTxtProxyChainPassword() { if (txtProxyChainPassword == null) { txtProxyChainPassword = new JPasswordField(); txtProxyChainPassword.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { proxyDialog.saveAndClose(); } }); } return txtProxyChainPassword; }
txtPasswordField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtPasswordFieldActionPerformed(evt);
public static void main(String args[]) { JFrame box = new JFrame("Password"); box.setVisible(true); box.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); box.setSize(400,100); JPasswordField pass = new JPasswordField(10); //add action listener pass.addActionListener(new AL()); //add the pass to the box box.add(pass); ; }
protected PasswordEditor() { super(); textField = new JPasswordField(); textField.addActionListener(this); textField.addFocusListener(this); }
public void addFieldListener(String fieldLabel, ActionListener listener) { Component c = this.fieldMap.get(fieldLabel); if (c != null) { if (c instanceof ZapTextField) { ((ZapTextField)c).addActionListener(listener); } else if (c instanceof JPasswordField) { ((JPasswordField)c).addActionListener(listener); } else if (c instanceof JComboBox) { ((JComboBox<?>)c).addActionListener(listener); } else if (c instanceof JCheckBox) { ((JCheckBox)c).addActionListener(listener); } else { logger.error("Unrecognised field class " + fieldLabel + ": " + c.getClass().getCanonicalName()); } } }
passWord.addActionListener(new AL()); getContentPane().add(passWord);
Passwordfld.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {
/** * Prompt for a password, and wait until the user enters it. * @param prompt The prompt string * @return The new password. */ @SuppressWarnings("serial") private String getPassword(String prompt) { final JDialog input = new JDialog(mainWindow, "Prompt", true); input.setLayout(new FlowLayout()); input.add(new JLabel(prompt)); JPasswordField textField = new JPasswordField(10); input.add(textField); Action okAction = new AbstractAction("OK") { public void actionPerformed(ActionEvent e) { input.dispose(); } }; textField.addActionListener(okAction); JButton ok = new JButton(okAction); input.add(ok); input.pack(); input.setLocationRelativeTo(mainWindow); input.setVisible(true); // BLOCKING return new String(textField.getPassword()); }
private JPasswordField password; private String typedPassword; private final String defaultPassword = "yourDesiredPassword"; public void createPasswordField(){ password = new JPasswordField(30); password.setBounds(280, 240, 90, 20); password.setEchoChar('*'); password.setBackground(Color.white); password.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { password = (JPasswordField) e.getSource(); char [] tempPass = password.getPassword(); typedPassword = new String(tempPass); if (!typedPassword.equals(defaultPassword)){ JOptionPane.showMessageDialog(null, "Your password is not correct", "Stack Over Flow example", JOptionPane.ERROR_MESSAGE); } } }); }
/** * Prompt for a password, and wait until the user enters it. * @param prompt The prompt string * @return The new password. */ @SuppressWarnings("serial") private String getPassword(String prompt) { final JDialog input = new JDialog(mainWindow, "Prompt", true); input.setLayout(new FlowLayout()); input.add(new JLabel(prompt)); JPasswordField textField = new JPasswordField(10); input.add(textField); Action okAction = new AbstractAction("OK") { public void actionPerformed(ActionEvent e) { input.dispose(); } }; textField.addActionListener(okAction); JButton ok = new JButton(okAction); input.add(ok); input.pack(); input.setLocationRelativeTo(mainWindow); input.setVisible(true); // BLOCKING return new String(textField.getPassword()); }
JPassword = new JPasswordField(20); JPassword.setEchoChar('*'); JPassword.addActionListener(okListener); gridBag.setConstraints(JPassword, c); proxyPanel.add(JPassword);
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame frame = new JFrame("Password Login System"); frame.setSize(400, 100); frame.setResizable(false); frame.setVisible(true); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); JPanel panel = new JPanel(); JLabel label = new JLabel("Enter Password: "); JPasswordField pass = new JPasswordField(10); pass.setEchoChar('*'); pass.addActionListener(new AL()); panel.add(label, BorderLayout.WEST); panel.add(pass, BorderLayout.EAST); frame.add(panel); frame.validate(); } }); }
passwordField.addActionListener(closeDialogActionListener); dialog.getContentPane().add(passwordField, BorderLayout.CENTER); JButton okButton = new JButton("ok");
private void initComponents() { glassPane = new JWaitGlassPane(JWaitGlassPane.TYPE_DIRECTION_PING_PONG, "", null, null); //$NON-NLS-1$ loginComboBoxModel = new LoginComboBoxModel(); loginBox = new JComboBox(loginComboBoxModel); loginBox.setEditable(true); loginField = (JTextField) loginBox.getEditor().getEditorComponent(); loginField.addActionListener(connectionAction); loginField.getDocument().addDocumentListener(new LoginDocumentListener()); passwordField = new JPasswordField(); passwordField.addActionListener(connectionAction); loginField.setPreferredSize(passwordField.getPreferredSize()); passwordField.setPreferredSize(loginBox.getPreferredSize()); saveLoginBox = new JCheckBox(ProfilMessages.getString("LoginDialog.5")); //$NON-NLS-1$ saveLoginBox.addChangeListener(new SaveLoginBoxChangeListener()); savePasswordBox = new JCheckBox(ProfilMessages.getString("LoginDialog.6")); //$NON-NLS-1$ savePasswordBox.setEnabled(false); iconKeyLabel = new JLabel(ICON_KEY); deleteButton = new JButton(deleteAction); deleteButton.setBorderPainted(false); deleteButton.setFocusable(false); }
public VPasswordField(String aText) { super.setText(aText != null ? aText : ""); if (aText == null) { nullValue = true; } oldValue = aText; super.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { checkValueChanged(); } }); super.addActionListener((java.awt.event.ActionEvent e) -> { checkValueChanged(); }); }
hacWebrootTextField.addActionListener(action->saveSettings()); loginTextField.addActionListener(action->saveSettings()); passwordField.addActionListener(action->saveSettings()); testConnectionButton.addActionListener(action->testConnection());
@Override JPasswordField initSwingComponent() { TextField textField = getAWTComponent(); JPasswordField swingComponent = new JPasswordField(); swingComponent.setText(textField.getText()); swingComponent.setColumns(textField.getColumns()); swingComponent.setEchoChar(textField.getEchoChar()); swingComponent.setEditable(textField.isEditable()); swingComponent.select(textField.getSelectionStart(), textField.getSelectionEnd()); swingComponent.addActionListener(new SwingTextFieldListener()); return swingComponent; }