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);
}
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);
}
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;
}
}
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);
}
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");
}
}
Aggregations