Codota Logo
JPasswordField.<init>
Code IndexAdd Codota to your IDE (free)

How to use
javax.swing.JPasswordField
constructor

Best Java code snippets using javax.swing.JPasswordField.<init> (Showing top 20 results out of 1,827)

Refine searchRefine arrow

  • JTextField.<init>
  • JLabel.<init>
  • JPanel.<init>
  • JButton.<init>
  • Container.add
  • Common ways to obtain JPasswordField
private void myMethod () {
JPasswordField j =
  • Codota Iconnew JPasswordField()
  • Codota Iconnew JPasswordField(int1)
  • Codota IconString str;new JPasswordField(str)
  • Smart code suggestions by Codota
}
origin: stackoverflow.com

 JPanel panel = new JPanel();
JLabel label = new JLabel("Enter a password:");
JPasswordField pass = new JPasswordField(10);
panel.add(label);
panel.add(pass);
String[] options = new String[]{"OK", "Cancel"};
int option = JOptionPane.showOptionDialog(null, panel, "The title",
             JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE,
             null, options, options[1]);
if(option == 0) // pressing OK button
{
  char[] password = pass.getPassword();
  System.out.println("Your password is: " + new String(password));
}
origin: stackoverflow.com

 JTextField username = new JTextField();
JTextField password = new JPasswordField();
Object[] message = {
  "Username:", username,
  "Password:", password
};

int option = JOptionPane.showConfirmDialog(null, message, "Login", JOptionPane.OK_CANCEL_OPTION);
if (option == JOptionPane.OK_OPTION) {
  if (username.getText().equals("h") && password.getText().equals("h")) {
    System.out.println("Login successful");
  } else {
    System.out.println("login failed");
  }
} else {
  System.out.println("Login canceled");
}
origin: stackoverflow.com

 JTextField firstName = new JTextField();
JTextField lastName = new JTextField();
JPasswordField password = new JPasswordField();
final JComponent[] inputs = new JComponent[] {
    new JLabel("First"),
    firstName,
    new JLabel("Last"),
    lastName,
    new JLabel("Password"),
    password
};
int result = JOptionPane.showConfirmDialog(null, inputs, "My custom dialog", JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
  System.out.println("You entered " +
      firstName.getText() + ", " +
      lastName.getText() + ", " +
      password.getText());
} else {
  System.out.println("User canceled / closed the dialog, result = " + result);
}
origin: alibaba/jstorm

                   String[] prompt,
                   boolean[] echo) {
panel = new JPanel();
panel.setLayout(new GridBagLayout());
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridx = 0;
panel.add(new JLabel(instruction), gbc);
gbc.gridy++;
  gbc.gridx = 0;
  gbc.weightx = 1;
  panel.add(new JLabel(prompt[i]), gbc);
  gbc.weighty = 1;
  if (echo[i]) {
    texts[i] = new JTextField(20);
  } else {
    texts[i] = new JPasswordField(20);
  panel.add(texts[i], gbc);
  gbc.gridy++;
origin: com.darwinsys/darwinsys-api

/**
 * 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());
}
origin: stackoverflow.com

 public class TestPane extends JPanel {

  public TestPane() {

    Random rnd = new Random();

    JPanel panel = new JPanel();
    JPasswordField pf = new JPasswordField(10);
    JButton btn = new JButton("Login");
    panel.add(pf);
    panel.add(btn);

    panel.setBorder(new EmptyBorder(rnd.nextInt(10), rnd.nextInt(10), rnd.nextInt(10), rnd.nextInt(10)));
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(rnd.nextInt(100), rnd.nextInt(100), rnd.nextInt(100), rnd.nextInt(100));

    add(panel, gbc);

  }

}
origin: stackoverflow.com

 public class PasswordForm {
 private static String password = "mypass";
 public static void main(String[] args){
 //Swing operations should happen on the EDT
 EventQueue.invokeAndWait( new Runnable(){
    public void run(){
      //whole UI creation
      final JTextField usernameInput = new JTextField(10);
      final JPasswordField passwordInput = new JPasswordField(10);
      //more UI creation
      JButton loginInput = new JButton("Login");
      loginInput.addActionListener(new ActionListener(){
       public void actionPerformed(ActionEvent e){
        JOptionPane.showMessageDialog(null,"Username is:" + usernameInput.getText() + " Password is:" + passwordInput.getText());
       }
      });
    }
   } //todo catch the exceptions from the invokeAndWait call
 }
}
origin: mguessan/davmail

protected JPanel getKeystorePanel() {
  JPanel keyStorePanel = new JPanel(new GridLayout(4, 2));
  keyStorePanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_DAVMAIL_SERVER_CERTIFICATE")));
  keystoreTypeCombo = new JComboBox(new String[]{"JKS", "PKCS12"});
  keystoreTypeCombo.setSelectedItem(Settings.getProperty("davmail.ssl.keystoreType"));
  keystoreFileField = new JTextField(Settings.getProperty("davmail.ssl.keystoreFile"), 20);
  keystorePassField = new JPasswordField(Settings.getProperty("davmail.ssl.keystorePass"), 20);
  keyPassField = new JPasswordField(Settings.getProperty("davmail.ssl.keyPass"), 20);
  addSettingComponent(keyStorePanel, BundleMessage.format("UI_KEY_STORE_TYPE"), keystoreTypeCombo,
      BundleMessage.format("UI_KEY_STORE_TYPE_HELP"));
  addSettingComponent(keyStorePanel, BundleMessage.format("UI_KEY_STORE"), keystoreFileField,
      BundleMessage.format("UI_KEY_STORE_HELP"));
  addSettingComponent(keyStorePanel, BundleMessage.format("UI_KEY_STORE_PASSWORD"), keystorePassField,
      BundleMessage.format("UI_KEY_STORE_PASSWORD_HELP"));
  addSettingComponent(keyStorePanel, BundleMessage.format("UI_KEY_PASSWORD"), keyPassField,
      BundleMessage.format("UI_KEY_PASSWORD_HELP"));
  updateMaximumSize(keyStorePanel);
  return keyStorePanel;
}
origin: stackoverflow.com

f.setLayout(new GridLayout(0, 1));
f.add(Laf.createToolBar(f));
f.add(new JTextField("bla@foo.com"));
f.add(new JPasswordField("*****"));
f.pack();
f.setLocationRelativeTo(null);
origin: stackoverflow.com

private final JPasswordField passwordField = new JPasswordField(12);
private boolean gainedFocusBefore;
 super(new FlowLayout());
 add(new JLabel("Password: "));
 add(passwordField);
origin: stackoverflow.com

 public class TestPane{

public static void main (String[] args) {

  Random rnd = new Random();

  JFrame frame = new JFrame();
  JPasswordField pf = new JPasswordField();
  JButton btn = new JButton("Login");
  frame.setSize(500, 500);
  frame.setLayout(null);
  btn.setBounds(y, x, width, height);
  pf.setBounds(y, x, width, height);
  frame.add(btn);
  frame.add(pf);        
}

}
origin: stackoverflow.com

JLabel usrNameLabel = new JLabel("User Name");
changeCompFont(usrNameLabel);
JTextField usrNameFeild = new JTextField("user name");
changeCompFont(usrNameFeild);
usrNameLabel.setLabelFor(usrNameFeild);
JLabel passwordLabel = new JLabel("Password");
changeCompFont(passwordLabel);
JPasswordField passFeild = new JPasswordField("Password");
changeCompFont(passFeild);
passFeild.setBorder(compundBorder);
add(usrNameLabel, labCnst);
add(usrNameFeild, txtCnst);
add(passwordLabel, labCnst);
add(passFeild, txtCnst);
origin: apache/pdfbox

JPanel panel = new JPanel();
JLabel label = new JLabel("Password:");
JPasswordField pass = new JPasswordField(10);
panel.add(label);
panel.add(pass);
origin: marytts/marytts

lName = new javax.swing.JLabel();
lName1 = new javax.swing.JLabel();
tfUser = new javax.swing.JTextField();
passwordField = new javax.swing.JPasswordField();
origin: IanDarwin/darwinsys-api

/**
 * 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());
}
origin: stackoverflow.com

 JPanel panel = new JPanel();
JPasswordField pass = new JPasswordField(10)
{
  public void addNotify()
  {
    panel.addNotify();
    requestFocus();
  }
};
panel.add(pass);
JOptionPane pane = new JOptionPane();
JButton btnOK = new JButton("OK");
JButton btnCancel = new JButton("Cancel");
Object[] options = {btnOK, btnCancel};
pane.showOptionDialog(null, panel, "Enter the password", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, null);
origin: stackoverflow.com

userName = new JTextField("");
userName.setText("Username");
userName.setForeground(Color.GRAY);
JPasswordField passWord = new JPasswordField(10);
passWord.setEchoChar('*');
passWord.addActionListener(new AL());
b1 = new JButton("something");
getContentPane().add(b1);
origin: stackoverflow.com

 tf = new JTextField("Cool Beans");
tf2 = new JTextField("UnCool Beans");
tf3 = new JTextField("Hot Beans");
pf = new JPasswordField("password");
origin: stackoverflow.com

 JLabel label = new JLabel("Password") {
  @Override public Dimension getMaximumSize() {
    return super.getPreferredSize();
  }
};
JPasswordField field = new JPasswordField() {
  @Override public Dimension getMaximumSize() {
    return super.getPreferredSize();
  }
};
origin: runelite/runelite

JLabel title = new JLabel(name);
title.setForeground(Color.WHITE);
title.setToolTipText("<html>" + name + ":<br>" + listItem.getDescription() + "</html>");
  JPanel item = new JPanel();
  item.setLayout(new BorderLayout());
  item.setMinimumSize(new Dimension(PANEL_WIDTH, 0));
  name = cid.getItem().name();
  JLabel configEntryName = new JLabel(name);
  configEntryName.setForeground(Color.WHITE);
  configEntryName.setToolTipText("<html>" + name + ":<br>" + cid.getItem().description() + "</html>");
      textField = new JPasswordField();
      colorPickerBtn = new JButton("Pick a color");
      colorPickerBtn = new JButton(ColorUtil.toHexColor(existingColor).toUpperCase());
    JPanel dimensionPanel = new JPanel();
    dimensionPanel.setLayout(new BorderLayout());
    dimensionPanel.add(new JLabel(" x "), BorderLayout.CENTER);
    dimensionPanel.add(heightSpinner, BorderLayout.EAST);
JButton resetButton = new JButton("Reset");
resetButton.addActionListener((e) ->
javax.swingJPasswordField<init>

Popular methods of JPasswordField

  • getPassword
  • setText
  • setEnabled
  • addActionListener
  • addKeyListener
  • setColumns
  • getDocument
  • setEchoChar
  • requestFocusInWindow
  • setEditable
  • setPreferredSize
  • addFocusListener
  • setPreferredSize,
  • addFocusListener,
  • setFont,
  • setToolTipText,
  • setName,
  • getEchoChar,
  • getText,
  • requestFocus,
  • setDocument

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Join (org.hibernate.mapping)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now