/** * Builds a new {@code PasswordType}. * @param columns * The number of columns for the underlying component. */ public PasswordType(int columns) { comp.setColumns(columns); }
/** * Builds a new {@code PasswordType} with 5 columns. */ public PasswordType() { comp.setColumns(5); }
protected void createServerPassPhrase() { $objectMap.put("serverPassPhrase", serverPassPhrase = new JPasswordField()); serverPassPhrase.setName("serverPassPhrase"); serverPassPhrase.setColumns(15); }
/** * Builds a new {@code PasswordType}. * @param columns * The number of columns for the underlying component. * @param isEditable * To specify if the component can be edited or not. */ public PasswordType(int columns, boolean isEditable) { comp.setColumns(columns); comp.setEditable(isEditable); }
JLabel label = new JLabel("Password") { @Override public Dimension getMaximumSize() { return super.getPreferredSize(); } }; JPasswordField field = new JPasswordField() { @Override public Dimension getMaximumSize() { return super.getPreferredSize(); } }; field.setColumns(10); Box verticalBox = Box.createVerticalBox(); verticalBox.add(Box.createVerticalGlue()); verticalBox.add(label); verticalBox.add(field); verticalBox.add(Box.createVerticalGlue()); // Box horizontalBox = Box.createHorizontalBox(); horizontalBox.add(Box.createHorizontalGlue()); horizontalBox.add(verticalBox); horizontalBox.add(Box.createHorizontalGlue()); add(horizontalBox);
private void initComponents() { nameField = new JTextField(10); portField = new IntTextField(0, Integer.MAX_VALUE); portField.setColumns(7); passwordField = new JPasswordField(); passwordField.setColumns(10); comment = new JTextField(); comment.setColumns(20); }
public static void main( String[] args ) { EventQueue.invokeLater( new Runnable() { @Override public void run() { JFrame testFrame = new JFrame( "Test" ); JPasswordField field = new JPasswordField( ); field.setColumns( 20 ); field.setText( "Password" ); testFrame.add( field ); testFrame.pack(); testFrame.setVisible( true ); testFrame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ); } } ); }
@Override public String getPassword(final String title) { final JPanel panel = new JPanel(); panel.setLayout(new MigLayout()); panel.add(new JLabel("Password:")); final JPasswordField password = new JPasswordField() { private static final long serialVersionUID = 1L; int counter = 15; @Override public void paint(Graphics g) { super.paint(g); if (counter > 0) { requestFocusInWindow(); counter--; } } }; password.setColumns(20); panel.add(password); int option = JOptionPane.showConfirmDialog(null, panel, title, JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.CANCEL_OPTION || option < 0) return null; return new String(password.getPassword()); }
protected void createServerConfirmPassPhrase() { $objectMap.put("serverConfirmPassPhrase", serverConfirmPassPhrase = new JPasswordField()); serverConfirmPassPhrase.setName("serverConfirmPassPhrase"); serverConfirmPassPhrase.setColumns(15); serverConfirmPassPhrase.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyReleased", this, "doKeyReleased__on__serverConfirmPassPhrase")); }
protected void createServerPassPhrase() { $objectMap.put("serverPassPhrase", serverPassPhrase = new JPasswordField()); serverPassPhrase.setName("serverPassPhrase"); serverPassPhrase.setColumns(15); serverPassPhrase.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyReleased", this, "doKeyReleased__on__serverPassPhrase")); }
JFrame f = new JFrame(); f.setLayout(new BorderLayout()); // JPanel stuffH = new JPanel(); f.add(stuffH, BorderLayout.CENTER); stuffH.setLayout(new BoxLayout(stuffH, BoxLayout.X_AXIS)); // JPanel stuffV = new JPanel(); stuffV.setLayout(new BoxLayout(stuffV, BoxLayout.Y_AXIS)); // JLabel label = new JLabel("Password"); BoxAdapter labelAdapter = new BoxAdapter(); labelAdapter.add(label); JPasswordField field = new JPasswordField(); field.setColumns(10); BoxAdapter fieldAdapter = new BoxAdapter(); fieldAdapter.add(field); // stuffV.add(new VerticalGlue()); // for vertical spacing stuffV.add(labelAdapter); stuffV.add(fieldAdapter); stuffV.add(new VerticalGlue()); // for vertical spacing // stuffH.add(new HorizontalGlue()); // for horizontal spacing stuffH.add(stuffV); stuffH.add(new HorizontalGlue()); // for horizontal spacing // f.setVisible(true); f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
@VisibleForTesting protected String promptForPassword() { return Interruptibles.awaitResult(() -> SwingAction.invokeAndWaitResult(() -> { final JPasswordField passwordField = new JPasswordField(); passwordField.setColumns(15); final JOptionPane optionPane = new JOptionPane( passwordField, JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION) { private static final long serialVersionUID = -6461902648509091914L; @Override public void selectInitialValue() { super.selectInitialValue(); passwordField.requestFocusInWindow(); } }; optionPane.createDialog(parentComponent, "Enter a password to join the game").setVisible(true); return new String(passwordField.getPassword()); })).result.orElse(""); } }
add(field); passwordField=new JPasswordField(); passwordField.setColumns(10); add(passwordField); addMouseListener(new MouseClickAdapter());
_passwordText.setColumns(15);
public PasswordEditableField() { super(true); textField = new JPasswordField(); textField.setColumns(15); addSaveFocusListener(textField); addSaveAndCancelKeyListeners(textField); addFieldChangeKeyListener(textField); this.setRejectButtonVisible(false); }
public JComponent create() { JPasswordField password = new JPasswordField(); if (hasAttribute("size")) { int size = GeneralUtil.parseIntRelaxed(getAttribute("size")); // Size of 0 doesn't make any sense, so use default value if (size == 0) { password.setColumns(15); } else { password.setColumns(size); } } else { password.setColumns(15); } if (hasAttribute("maxlength")) { password.setDocument( new SizeLimitedDocument( GeneralUtil.parseIntRelaxed(getAttribute("maxlength")))); } if (hasAttribute("readonly") && getAttribute("readonly").equalsIgnoreCase("readonly")) { password.setEditable(false); } return password; }
public JComponent create() { JPasswordField password = new JPasswordField(); if (hasAttribute("size")) { int size = GeneralUtil.parseIntRelaxed(getAttribute("size")); // Size of 0 doesn't make any sense, so use default value if (size == 0) { password.setColumns(15); } else { password.setColumns(size); } } else { password.setColumns(15); } if (hasAttribute("maxlength")) { password.setDocument( new SizeLimitedDocument( GeneralUtil.parseIntRelaxed(getAttribute("maxlength")))); } if (hasAttribute("readonly") && getAttribute("readonly").equals("readonly")) { password.setEditable(false); } return password; }
public JComponent create() { JPasswordField password = new JPasswordField(); if (hasAttribute("size")) { int size = GeneralUtil.parseIntRelaxed(getAttribute("size")); // Size of 0 doesn't make any sense, so use default value if (size == 0) { password.setColumns(15); } else { password.setColumns(size); } } else { password.setColumns(15); } if (hasAttribute("maxlength")) { password.setDocument( new SizeLimitedDocument( GeneralUtil.parseIntRelaxed(getAttribute("maxlength")))); } if (hasAttribute("readonly") && getAttribute("readonly").equalsIgnoreCase("readonly")) { password.setEditable(false); } return password; }
public JComponent create() { JPasswordField password = new JPasswordField(); if (hasAttribute("size")) { int size = GeneralUtil.parseIntRelaxed(getAttribute("size")); // Size of 0 doesn't make any sense, so use default value if (size == 0) { password.setColumns(15); } else { password.setColumns(size); } } else { password.setColumns(15); } if (hasAttribute("maxlength")) { password.setDocument( new SizeLimitedDocument( GeneralUtil.parseIntRelaxed(getAttribute("maxlength")))); } if (hasAttribute("readonly") && getAttribute("readonly").equalsIgnoreCase("readonly")) { password.setEditable(false); } return password; }
@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; }