Search in sources :

Example 86 with JPasswordField

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);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) VerticalPanel(org.apache.jmeter.gui.util.VerticalPanel) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField) ButtonGroup(javax.swing.ButtonGroup) HorizontalPanel(org.apache.jmeter.gui.util.HorizontalPanel) SecuritySettingsPanel(org.apache.jmeter.protocol.smtp.sampler.gui.SecuritySettingsPanel)

Example 87 with JPasswordField

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);
        }
    });
}
Also used : JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) KeyAdapter(java.awt.event.KeyAdapter) JLabel(javax.swing.JLabel) LinkButton(com.sk89q.mclauncher.util.LinkButton) JCheckBox(javax.swing.JCheckBox) KeyEvent(java.awt.event.KeyEvent) PopupMouseAdapter(com.sk89q.mclauncher.util.PopupMouseAdapter) ActionListener(java.awt.event.ActionListener) JPasswordField(javax.swing.JPasswordField)

Example 88 with JPasswordField

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);
}
Also used : JPasswordField(javax.swing.JPasswordField) IntTextField(games.strategy.ui.IntTextField) JTextField(javax.swing.JTextField)

Example 89 with JPasswordField

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());
}
Also used : JPasswordField(javax.swing.JPasswordField) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 90 with JPasswordField

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);
    }
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel)

Aggregations

JPasswordField (javax.swing.JPasswordField)100 JLabel (javax.swing.JLabel)60 JPanel (javax.swing.JPanel)47 JTextField (javax.swing.JTextField)44 BorderLayout (java.awt.BorderLayout)30 JButton (javax.swing.JButton)24 JCheckBox (javax.swing.JCheckBox)23 GridBagLayout (java.awt.GridBagLayout)22 GridBagConstraints (java.awt.GridBagConstraints)19 ActionEvent (java.awt.event.ActionEvent)19 ActionListener (java.awt.event.ActionListener)19 Insets (java.awt.Insets)18 Dimension (java.awt.Dimension)15 WindowAdapter (java.awt.event.WindowAdapter)12 WindowEvent (java.awt.event.WindowEvent)12 EmptyBorder (javax.swing.border.EmptyBorder)12 EtchedBorder (javax.swing.border.EtchedBorder)12 AbstractAction (javax.swing.AbstractAction)11 CompoundBorder (javax.swing.border.CompoundBorder)11 ItemEvent (java.awt.event.ItemEvent)7