Search in sources :

Example 51 with JPasswordField

use of javax.swing.JPasswordField in project zaproxy by zaproxy.

the class StandardFieldsDialog method addPasswordField.

/**
	 * Adds a {@link JPasswordField} field, with the given label and, optionally, the given value.
	 *
	 * @param fieldLabel the label of the field
	 * @param value the value of the field, might be {@code null}
	 * @throws IllegalArgumentException if the dialogue is a tabbed dialogue
	 * @since TODO add version
	 * @see #addPasswordField(int, String, String)
	 * @see #getPasswordValue(String)
	 */
public void addPasswordField(String fieldLabel, String value) {
    if (isTabbed()) {
        throw new IllegalArgumentException("Initialised as a tabbed dialog - must use method with tab parameters");
    }
    JPasswordField field = new JPasswordField();
    if (value != null) {
        field.setText(value);
    }
    this.addField(fieldLabel, field, field, 0.0D);
}
Also used : JPasswordField(javax.swing.JPasswordField)

Example 52 with JPasswordField

use of javax.swing.JPasswordField in project zaproxy by zaproxy.

the class StandardFieldsDialog method addPasswordField.

/**
	 * Adds a {@link JPasswordField} field to the tab with the given index, with the given label and, optionally, the given
	 * value.
	 *
	 * @param tabIndex the index of the tab
	 * @param fieldLabel the label of the field
	 * @param value the value of the field, might be {@code null}
	 * @throws IllegalArgumentException if the dialogue is not a tabbed dialogue or if the index does not correspond to an
	 *			 existing tab
	 * @since TODO add version
	 * @see #addPasswordField(String, String)
	 * @see #getPasswordValue(String)
	 */
public void addPasswordField(int tabIndex, String fieldLabel, String value) {
    if (!isTabbed()) {
        throw new IllegalArgumentException("Not initialised as a tabbed dialog - must use method without tab parameters");
    }
    if (tabIndex < 0 || tabIndex >= this.tabPanels.size()) {
        throw new IllegalArgumentException("Invalid tab index: " + tabIndex);
    }
    JPasswordField field = new JPasswordField();
    if (value != null) {
        field.setText(value);
    }
    this.addField(this.tabPanels.get(tabIndex), this.tabOffsets.get(tabIndex), fieldLabel, field, field, 0.0D);
    incTabOffset(tabIndex);
}
Also used : JPasswordField(javax.swing.JPasswordField)

Example 53 with JPasswordField

use of javax.swing.JPasswordField in project GNS by MobilityFirst.

the class UserInfoPrompted method promptKeyboardInteractive.

/**
   *
   * @param destination
   * @param name
   * @param instruction
   * @param prompt
   * @param echo
   * @return the array of strings
   */
@Override
public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo) {
    panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridx = 0;
    panel.add(new JLabel(instruction), gbc);
    gbc.gridy++;
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    JTextField[] texts = new JTextField[prompt.length];
    for (int i = 0; i < prompt.length; i++) {
        gbc.fill = GridBagConstraints.NONE;
        gbc.gridx = 0;
        gbc.weightx = 1;
        panel.add(new JLabel(prompt[i]), gbc);
        gbc.gridx = 1;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.weighty = 1;
        if (echo[i]) {
            texts[i] = new JTextField(20);
        } else {
            texts[i] = new JPasswordField(20);
        }
        panel.add(texts[i], gbc);
        gbc.gridy++;
    }
    if (JOptionPane.showConfirmDialog(null, panel, destination + ": " + name, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
        String[] response = new String[prompt.length];
        for (int i = 0; i < prompt.length; i++) {
            response[i] = texts[i].getText();
        }
        return response;
    } else {
        // cancel
        return null;
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagLayout(java.awt.GridBagLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Example 54 with JPasswordField

use of javax.swing.JPasswordField in project voltdb by VoltDB.

the class ConnectionDialogSwing method create.

private void create() {
    Box main = Box.createHorizontalBox();
    Box labels = Box.createVerticalBox();
    Box controls = Box.createVerticalBox();
    Box buttons = Box.createHorizontalBox();
    Box whole = Box.createVerticalBox();
    // (weconsultants@users) New code
    Box extra = Box.createHorizontalBox();
    main.add(Box.createHorizontalStrut(10));
    main.add(Box.createHorizontalGlue());
    main.add(labels);
    main.add(Box.createHorizontalStrut(10));
    main.add(Box.createHorizontalGlue());
    main.add(controls);
    main.add(Box.createHorizontalStrut(10));
    main.add(Box.createVerticalGlue());
    main.add(extra);
    main.add(Box.createVerticalGlue());
    whole.add(Box.createVerticalGlue());
    whole.add(Box.createVerticalStrut(10));
    whole.add(main);
    whole.add(Box.createVerticalGlue());
    whole.add(Box.createVerticalStrut(10));
    whole.add(buttons);
    whole.add(Box.createVerticalGlue());
    whole.add(Box.createVerticalStrut(10));
    whole.add(Box.createVerticalGlue());
    labels.add(createLabel("Recent Setting:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("Setting Name:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("Type:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("Driver:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("URL:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("User:"));
    labels.add(Box.createVerticalGlue());
    labels.add(createLabel("Password:"));
    labels.add(Box.createVerticalGlue());
    labels.add(Box.createVerticalStrut(10));
    controls.add(Box.createVerticalGlue());
    // (weconsultants@users) New code
    mSettingName.setActionCommand("Select Setting");
    mSettingName.addActionListener(this);
    controls.add(mSettingName);
    controls.add(Box.createHorizontalGlue());
    // (weconsultants@users) New code
    mName = new JTextField();
    mName.addActionListener(this);
    controls.add(mName);
    // (weconsultants@users) New code
    clear = new JButton("Clear Names");
    clear.setActionCommand("Clear");
    clear.addActionListener(this);
    buttons.add(clear);
    buttons.add(Box.createHorizontalGlue());
    buttons.add(Box.createHorizontalStrut(10));
    JComboBox types = new JComboBox();
    connTypes = ConnectionDialogCommon.getTypes();
    for (int i = 0; i < connTypes.length; i++) {
        types.addItem(connTypes[i][0]);
    }
    types.addItemListener(this);
    controls.add(types);
    controls.add(Box.createVerticalGlue());
    mDriver = new JTextField(connTypes[0][1]);
    mDriver.addActionListener(this);
    controls.add(mDriver);
    mURL = new JTextField(connTypes[0][2]);
    mURL.addActionListener(this);
    controls.add(mURL);
    controls.add(Box.createVerticalGlue());
    mUser = new JTextField("SA");
    mUser.addActionListener(this);
    controls.add(mUser);
    controls.add(Box.createVerticalGlue());
    mPassword = new JPasswordField("");
    mPassword.addActionListener(this);
    controls.add(mPassword);
    controls.add(Box.createVerticalGlue());
    controls.add(Box.createVerticalStrut(10));
    // The button bar
    buttons.add(Box.createHorizontalGlue());
    buttons.add(Box.createHorizontalStrut(10));
    okCancel = new JButton("     Ok      ");
    okCancel.setActionCommand("ConnectOk");
    okCancel.addActionListener(this);
    buttons.add(okCancel);
    getRootPane().setDefaultButton(okCancel);
    buttons.add(Box.createHorizontalGlue());
    buttons.add(Box.createHorizontalStrut(20));
    okCancel = new JButton("  Cancel   ");
    okCancel.setActionCommand("ConnectCancel");
    okCancel.addActionListener(this);
    buttons.add(okCancel);
    buttons.add(Box.createHorizontalGlue());
    buttons.add(Box.createHorizontalStrut(10));
    JPanel jPanel = new JPanel();
    jPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    jPanel.add("Center", whole);
    getContentPane().add("Center", jPanel);
    doLayout();
    pack();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = getSize();
    if (currentConnectionSetting != null) {
        mName.setText(currentConnectionSetting.getName());
        mDriver.setText(currentConnectionSetting.getDriver());
        mURL.setText(currentConnectionSetting.getUrl());
        mUser.setText(currentConnectionSetting.getUser());
        mPassword.setText(currentConnectionSetting.getPassword());
    }
    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
        setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else {
        setLocation(0, 0);
        setSize(d);
    }
    setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) JComboBox(javax.swing.JComboBox) JPasswordField(javax.swing.JPasswordField) JButton(javax.swing.JButton) Box(javax.swing.Box) JComboBox(javax.swing.JComboBox) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) EmptyBorder(javax.swing.border.EmptyBorder)

Example 55 with JPasswordField

use of javax.swing.JPasswordField in project jdk8u_jdk by JetBrains.

the class InsetsEncapsulation method run.

@Override
public void run() {
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    runTest(new JScrollBar());
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTableHeader(javax.swing.table.JTableHeader) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JScrollBar(javax.swing.JScrollBar) JTextPane(javax.swing.JTextPane) JToggleButton(javax.swing.JToggleButton) JSlider(javax.swing.JSlider) JMenuItem(javax.swing.JMenuItem) JComponent(javax.swing.JComponent) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JToolBar(javax.swing.JToolBar) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) JTable(javax.swing.JTable) JEditorPane(javax.swing.JEditorPane) JSpinner(javax.swing.JSpinner) JRootPane(javax.swing.JRootPane) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

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