Package javax.swing

Examples of javax.swing.JPasswordField


        panel.add(proxyUser, BorderLayout.CENTER);
        return panel;
    }

    private JPanel getProxyPassPanel() {
        proxyPass = new JPasswordField(5);

        JLabel label = new JLabel(JMeterUtils.getResString("password")); // $NON-NLS-1$
        label.setLabelFor(proxyPass);
        label.setFont(FONT_SMALL);
View Full Code Here


        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(FolderLabel);
        folderBox = new JTextField(INBOX, 20);
        addField(settingsPanel, folderLabel, folderBox, gbc);
View Full Code Here

        public static Component createInputPasswordComponent(final Object model,
                                                 final AttributeSet attrs,
                                                 final FormView view) {
            PlainDocument document = (PlainDocument) model;
            final JPasswordField passwordField = new JPasswordField();

            // Model
            if (document == null) {
                document = new FormTextModel(new Form(SimpleAttributeSet.EMPTY),
                                             SimpleAttributeSet.EMPTY);
            }
            passwordField.setDocument(document);

            // ActionPerformed
            passwordField.addActionListener(new ActionListener() {

                public void actionPerformed(final ActionEvent event) {
                    view.actionPerformed(event);
                }

            });

            // VALUE
            String attribute = (String)attrs.getAttribute(HTML.Attribute.VALUE);

            if (!Utilities.isEmptyString(attribute)) {
                passwordField.setText(attribute);
            }

            // SIZE
            setTextSize(passwordField, attrs, passwordField.getEchoChar());

            // TITLE
            setTitle(passwordField, attrs);

            // ACCESSKEY
View Full Code Here

        smtpLoginPane.add(smtpLoginField, BorderLayout.CENTER);
        smtpLoginPane.add(Box.createRigidArea(new Dimension(5,0)), BorderLayout.EAST);
        authPane.add(smtpLoginPane, BorderLayout.CENTER);
        JPanel smtpPasswordPane = new JPanel(new BorderLayout());
        smtpPasswordPane.add(new JLabel(JMeterUtils.getResString("mailer_password")), BorderLayout.WEST); // $NON-NLS-1$
        smtpPasswordField = new JPasswordField(10);
        smtpPasswordField.setEditable(true);
        smtpPasswordPane.add(smtpPasswordField, BorderLayout.CENTER);
        smtpPasswordPane.add(Box.createRigidArea(new Dimension(5,0)), BorderLayout.EAST);
        authPane.add(smtpPasswordPane, BorderLayout.EAST);
View Full Code Here

                state = State.UserEntry1;
        }

        // create user interface components to prompt for username and password
        JTextField username = new JTextField(2);
        JPasswordField password = new JPasswordField(2);
        JComponent focus = username;
        if (StringUtils.hasValue(lastUsername)) {
            username.setText(lastUsername);
            focus = password;
        }
        JLabel usernameLabel = new JLabel(resources.getString("Username"),
                SwingConstants.RIGHT);
        JLabel passwordLabel = new JLabel(resources.getString("Password"),
                SwingConstants.RIGHT);
        Dimension d = usernameLabel.getPreferredSize();
        d.width = Math.max(d.width, passwordLabel.getPreferredSize().width);
        usernameLabel.setPreferredSize(d);
        passwordLabel.setPreferredSize(d);

        // if "remember me" support is enabled, create a checkbox
        JCheckBox rememberMe = null;
        if (rememberMeDays > 0) {
            rememberMe = new JCheckBox(
                    resources.getString("Remember_Me.Prompt"));
            rememberMe.setToolTipText(resources.format(
                "Remember_Me.Tooltip_FMT", rememberMeDays));
            Font f = rememberMe.getFont();
            f = f.deriveFont(f.getSize2D() * 0.8f);
            rememberMe.setFont(f);
        }

        // prompt the user for credentials
        final String title = (StringUtils.hasValue(this.title) ? this.title
                : resources.getString("Title"));
        final Object[] message = new Object[] {
                resources.formatStrings("Prompt_FMT", getRequestingPrompt()),
                BoxUtils.vbox(5),
                BoxUtils.hbox(15, usernameLabel, 5, username),
                BoxUtils.hbox(15, passwordLabel, 5, password),
                BoxUtils.hbox(BoxUtils.GLUE, rememberMe),
                new JOptionPaneTweaker.GrabFocus(focus) };
        final int[] userChoice = new int[1];

        try {
            Runnable r = new Runnable() {
                public void run() {
                    userChoice[0] = JOptionPane.showConfirmDialog(
                        parentComponent, message, title,
                        JOptionPane.OK_CANCEL_OPTION,
                        JOptionPane.PLAIN_MESSAGE);
                }
            };
            if (SwingUtilities.isEventDispatchThread())
                r.run();
            else
                SwingUtilities.invokeAndWait(r);
        } catch (Exception e) {
        }

        // record metadata about this password request
        lastUrl = getEffectiveURL();
        lastTimestamp = System.currentTimeMillis();
        lastUsername = username.getText().trim();
        prefs.put(prefsKey(LAST_USERNAME), lastUsername);

        if (userChoice[0] == JOptionPane.OK_OPTION) {
            // if the user entered credentials, return them.
            if (rememberMe != null && rememberMe.isSelected())
                savePasswordToKeyring(lastUsername, password.getPassword());
            return new PasswordAuthentication(lastUsername,
                    password.getPassword());
        } else {
            // if the user cancelled the operation, abort.
            state = State.Cancelled;
            return null;
        }
View Full Code Here

     */
    public JTextFieldAdapter(JPasswordField original)
    {
        super();
        this.original = original;
        keyboardTextField = new JPasswordField();
        keyboardTextField.setFont(original.getFont());
        SynchronizeDocumentsAdapter.synchronizeTextFields(keyboardTextField, original);
    }
View Full Code Here

     */
    public JTextFieldAdapter(JPasswordField original, int keyFontSize)
    {
        super(keyFontSize);
        this.original = original;
        keyboardTextField = new JPasswordField();
        keyboardTextField.setFont(original.getFont());
        SynchronizeDocumentsAdapter.synchronizeTextFields(keyboardTextField, original);
    }
View Full Code Here

        while (true) {
            // ask the user for the relevant information to locate the
            // schedule.
            JTextField url = new JTextField(urlStr, 40);
            url.addFocusListener(new FocusHighlighter(url));
            JTextField password = new JPasswordField(passwordStr, 10);
            password.addFocusListener(new FocusHighlighter(password));
            String urlLabel = resources.getString("Import_Schedule.URL_Label");
            String passwordLabel =
                resources.getString("Import_Schedule.Password_Label");
            Object message = new Object[] {
                errorMessage,
                resources.getString("Import_Schedule.Instructions"),
                newHBox(new JLabel("  "+urlLabel+" "), url),
                newHBox(new JLabel("  "+passwordLabel+" "), password) };
            if (JOptionPane.showConfirmDialog
                (frame, message,
                 resources.getString("Import_Schedule.Dialog_Title"),
                 JOptionPane.OK_CANCEL_OPTION)
                != JOptionPane.OK_OPTION)
                // if the user didn't hit the OK button, return null.
                return null;

            urlStr = url.getText();
            passwordStr = password.getText();

            if (urlStr == null || urlStr.trim().length() == 0) {
                errorMessage = resources.getString
                    ("Import_Schedule.URL_Missing");
                continue;
View Full Code Here

  private JPanel createPasswordPane() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
    panel.setBorder(BorderFactory.createTitledBorder("Password"));

    passwordField = new JPasswordField();
    passwordField.addActionListener(createFieldActionListener());
    panel.add(passwordField);

    return panel;
  }
View Full Code Here

          //store off existing value
          String existingValue = "";
          String existingTestUserPass = "";
          JTextField current = fieldMappings.get("Password:");
          if(current instanceof JPasswordField){
            JPasswordField pass = ((JPasswordField)current);
            if(pass!=null){
              char[] charArray = pass.getPassword();
              if(charArray.length>0){
              existingValue = new String(charArray);
              }
            }
          }else{
            existingValue = current.getText();
          }
          //save off test user password as well
          if(testUserPasswordValue instanceof JPasswordField){
            JPasswordField pass = ((JPasswordField)testUserPasswordValue);
            if(pass!=null){
              char[] charArray = pass.getPassword();
              if(charArray.length>0){
              existingTestUserPass = new String(charArray);
              }
            }
          }else{
            existingTestUserPass=testUserPasswordValue.getText();
          }
         
          JTextField updatedContainer = null;
          if(showPasswords.isSelected()){
            updatedContainer = new JTextField(textBoxWidth);
            updatedContainer.setText(existingValue);
            testUserPasswordValue = new JTextField(textBoxWidth);
            testUserPasswordValue.setText(existingTestUserPass);
          }else{
            updatedContainer = new JPasswordField(textBoxWidth);
            updatedContainer.setText(existingValue);
            testUserPasswordValue = new JPasswordField(textBoxWidth);
            testUserPasswordValue.setText(existingTestUserPass);
          }
          //locate the JPanel and rebuild it Should be at index 3
          JPanel passwordRow = (JPanel) top.getComponent(3);
//          JTextField jf = (JTextField) passwordRow.getComponent(1);
          //store off existing components
          Component[] existing = new Component[passwordRow.getComponentCount()];
          for(int i=0; i<passwordRow.getComponentCount();i++){
            existing[i] = passwordRow.getComponent(i);
          }
          passwordRow.removeAll();
          for(int j=0;j<existing.length;j++){
            if(j==1){//insert new JTextField instead
              passwordRow.add(updatedContainer);
            }else{
              passwordRow.add(existing[j]);
            }
          }
          //reload testUserRegion
          //store off existing components
          Component[] existingTest = new Component[testUserRegion.getComponentCount()];
          for(int i=0; i<testUserRegion.getComponentCount();i++){
            existingTest[i] = testUserRegion.getComponent(i);
          }
          testUserRegion.removeAll();
          for(int j=0;j<existingTest.length;j++){
            if(j==3){//insert new JTextField instead
              testUserRegion.add(testUserPasswordValue);
            }else{
              testUserRegion.add(existingTest[j]);
            }
          }
         
          top.revalidate();
          top.repaint();
        }
      })
      }
    });
    securityPanel.add(showPasswords);
    ssl = new JCheckBox("SSL:");
    ssl.setEnabled(false);
    securityPanel.add(ssl);
    top.add(securityPanel);
   
    // test user auth region
    testUserRegion = new JPanel();
    testUserRegion.setLayout(new FlowLayout(FlowLayout.LEFT));
    LineBorder border = new LineBorder(Color.BLUE, 2);
    TitledBorder tBorder = new TitledBorder(border, "Authentication/Authorization Check Credentials: (insert valid ldap user assigned to group)");
    testUserRegion.setBorder(tBorder);
    JLabel testUserName = new JLabel("Test UserName:");
    testUserNameValue = new JTextField(textBoxWidth);
    JLabel testUserPassword = new JLabel("Test Password:");
//    testUserPasswordValue = new JTextField(textBoxWidth);
    testUserPasswordValue = new JPasswordField(textBoxWidth);
    testUserRegion.add(testUserName);
    testUserRegion.add(testUserNameValue);
    testUserRegion.add(testUserPassword);
    testUserRegion.add(testUserPasswordValue);
    top.add(testUserRegion);
View Full Code Here

TOP

Related Classes of javax.swing.JPasswordField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.