final JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
final JTextField[] texts = new JTextField[items.length];
for (int i = 0; i < items.length; i++) {
CredentialItem item = items[i];
if (item instanceof CredentialItem.StringType
|| item instanceof CredentialItem.CharArrayType) {
gbc.fill = GridBagConstraints.NONE;
gbc.gridwidth = GridBagConstraints.RELATIVE;
gbc.gridx = 0;
panel.add(new JLabel(item.getPromptText()), gbc);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridwidth = GridBagConstraints.RELATIVE;
gbc.gridx = 1;
if (item.isValueSecure())
texts[i] = new JPasswordField(20);
else
texts[i] = new JTextField(20);
panel.add(texts[i], gbc);
gbc.gridy++;
} else if (item instanceof CredentialItem.InformationalMessage) {
gbc.fill = GridBagConstraints.NONE;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridx = 0;
panel.add(new JLabel(item.getPromptText()), gbc);
gbc.gridy++;
} else {
throw new UnsupportedCredentialItem(uri, item.getPromptText());
}
}
if (JOptionPane.showConfirmDialog(null, panel,
UIText.get().authenticationRequired,
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.OK_OPTION)
return false; // cancel
for (int i = 0; i < items.length; i++) {
CredentialItem item = items[i];
JTextField f = texts[i];
if (item instanceof CredentialItem.StringType) {
CredentialItem.StringType v = (CredentialItem.StringType) item;
if (f instanceof JPasswordField)