use of javax.swing.JPasswordField in project jmeter by apache.
the class MailReaderSamplerGui method init.
/*
* Helper method to set up the GUI screen
*/
private void init() {
// WARNING: called from ctor so must not be overridden (i.e. must be private or final)
setLayout(new BorderLayout());
setBorder(makeBorder());
JPanel settingsPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = getConstraints();
serverTypeBox = new JTextField(20);
serverTypeBox.addActionListener(this);
serverTypeBox.addFocusListener(this);
addField(settingsPanel, serverTypeLabel, serverTypeBox, gbc);
serverBox = new JTextField(20);
addField(settingsPanel, serverLabel, serverBox, gbc);
portBox = new JTextField(20);
addField(settingsPanel, portLabel, portBox, gbc);
usernameBox = new JTextField(20);
addField(settingsPanel, accountLabel, usernameBox, gbc);
passwordBox = new JPasswordField(20);
addField(settingsPanel, passwordLabel, passwordBox, gbc);
folderLabel = new JLabel(folderLabelStr);
folderBox = new JTextField(INBOX, 20);
addField(settingsPanel, folderLabel, folderBox, gbc);
HorizontalPanel numMessagesPanel = new HorizontalPanel();
numMessagesPanel.add(new JLabel(numMessagesLabel));
ButtonGroup nmbg = new ButtonGroup();
allMessagesButton = new JRadioButton(allMessagesLabel);
allMessagesButton.addChangeListener(e -> {
if (allMessagesButton.isSelected()) {
someMessagesField.setEnabled(false);
}
});
someMessagesButton = new JRadioButton();
someMessagesButton.addChangeListener(e -> {
if (someMessagesButton.isSelected()) {
someMessagesField.setEnabled(true);
}
});
nmbg.add(allMessagesButton);
nmbg.add(someMessagesButton);
someMessagesField = new JTextField(5);
allMessagesButton.setSelected(true);
numMessagesPanel.add(allMessagesButton);
numMessagesPanel.add(someMessagesButton);
numMessagesPanel.add(someMessagesField);
headerOnlyBox = new JCheckBox(headerOnlyLabel);
deleteBox = new JCheckBox(deleteLabel);
storeMimeMessageBox = new JCheckBox(storeMime);
securitySettingsPanel = new SecuritySettingsPanel();
JPanel settings = new VerticalPanel();
settings.add(Box.createVerticalStrut(5));
settings.add(settingsPanel);
settings.add(numMessagesPanel);
settings.add(headerOnlyBox);
settings.add(deleteBox);
settings.add(storeMimeMessageBox);
settings.add(securitySettingsPanel);
add(makeTitlePanel(), BorderLayout.NORTH);
add(settings, BorderLayout.CENTER);
}
use of javax.swing.JPasswordField in project SKMCLauncher by SKCraft.
the class LaunchOptions method addComponents.
private void addComponents() {
setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
final JLabel jarLabel = new JLabel("Active JAR:", SwingConstants.LEFT);
JLabel userLabel = new JLabel("Username:", SwingConstants.LEFT);
JLabel passLabel = new JLabel("Password:", SwingConstants.LEFT);
jarCombo = new JComboBox();
userText = new JComboBox();
userText.setModel(options.getIdentities());
userText.setEditable(true);
passText = new JPasswordField(20);
jarLabel.setLabelFor(jarCombo);
userLabel.setLabelFor(userText);
passLabel.setLabelFor(passText);
layout.setConstraints(jarCombo, fieldC);
layout.setConstraints(userText, fieldC);
layout.setConstraints(passText, fieldC);
rememberPass = new JCheckBox("Remember my password");
rememberPass.setBorder(null);
autoConnectCheck = new JCheckBox("Auto-connect");
autoConnectCheck.setBorder(null);
forceUpdateCheck = new JCheckBox("Force a game update");
forceUpdateCheck.setBorder(null);
changeComponentsCheck = new JCheckBox("Re-select install options (if any)");
changeComponentsCheck.setBorder(null);
playOfflineCheck = new JCheckBox("Play in offline mode");
playOfflineCheck.setBorder(null);
showConsoleCheck = new JCheckBox("Show messages and errors");
showConsoleCheck.setBorder(null);
expandBtn = new LinkButton("More options...");
final JPanel expandContainer = new JPanel();
expandContainer.setLayout(new BoxLayout(expandContainer, BoxLayout.X_AXIS));
expandContainer.setBorder(null);
expandContainer.add(expandBtn);
expandContainer.add(Box.createHorizontalGlue());
add(jarLabel, labelC);
add(jarCombo, fieldC);
add(userLabel, labelC);
add(userText, fieldC);
add(passLabel, labelC);
add(passText, fieldC);
add(rememberPass, checkboxC);
add(autoConnectCheck, checkboxC);
add(forceUpdateCheck, checkboxC);
add(changeComponentsCheck, checkboxC);
add(playOfflineCheck, checkboxC);
add(showConsoleCheck, checkboxC);
add(expandContainer, checkboxC);
autoConnectCheck.setVisible(false);
jarLabel.setVisible(false);
jarCombo.setVisible(false);
forceUpdateCheck.setVisible(false);
changeComponentsCheck.setVisible(false);
showConsoleCheck.setVisible(false);
playOfflineCheck.setVisible(false);
userText.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
loadSavedPassword();
}
});
loadSavedPassword();
userText.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
frame.launch();
}
}
});
userText.getEditor().getEditorComponent().addMouseListener(new PopupMouseAdapter() {
@Override
protected void showPopup(MouseEvent e) {
popupIdentityMenu(e.getComponent(), e.getX(), e.getY());
}
});
passText.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
frame.launch();
}
}
});
playOfflineCheck.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean selected = ((JCheckBox) e.getSource()).isSelected();
userText.setEnabled(!selected);
passText.setEnabled(!selected);
rememberPass.setEnabled(!selected);
}
});
expandBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
expandContainer.setVisible(false);
jarLabel.setVisible(true);
jarCombo.setVisible(true);
forceUpdateCheck.setVisible(true);
changeComponentsCheck.setVisible(true);
showConsoleCheck.setVisible(true);
playOfflineCheck.setVisible(true);
// registerAccount.setVisible(true);
}
});
}
use of javax.swing.JPasswordField in project triplea by triplea-game.
the class ServerOptions method initComponents.
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);
}
use of javax.swing.JPasswordField in project triplea by triplea-game.
the class ClientLogin method promptForPassword.
@VisibleForTesting
protected String promptForPassword() {
final JPasswordField passwordField = new JPasswordField();
passwordField.setColumns(15);
JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(parentComponent), passwordField, "Enter a password to join the game", JOptionPane.QUESTION_MESSAGE);
return new String(passwordField.getPassword());
}
use of javax.swing.JPasswordField in project triplea by triplea-game.
the class SetPasswordAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
final JLabel label = new JLabel("Enter Password, (Leave blank for no password).");
final JPasswordField passwordField = new JPasswordField();
final JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(label, BorderLayout.NORTH);
panel.add(passwordField, BorderLayout.CENTER);
final int selectedOption = JOptionPane.showOptionDialog(JOptionPane.getFrameForComponent(parent), panel, "Enter Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);
if (selectedOption != JOptionPane.OK_OPTION) {
return;
}
final String password = new String(passwordField.getPassword());
final boolean passworded;
if (password.trim().length() > 0) {
validator.setGamePassword(password);
passworded = true;
} else {
validator.setGamePassword(null);
passworded = false;
}
if (lobbyWatcher != null && lobbyWatcher.isActive()) {
lobbyWatcher.setPassworded(passworded);
}
}
Aggregations