JPanel connectionPanel;
JLabel userNameLabel = new JLabel(username + ": ", JLabel.RIGHT);
JTextField userNameField = new JTextField("");
JLabel passwordLabel = new JLabel(password + ": ", JLabel.RIGHT);
JTextField passwordField = new JPasswordField("");
connectionPanel = new JPanel(false);
connectionPanel.setLayout(new BoxLayout(connectionPanel, BoxLayout.X_AXIS));
JPanel namePanel = new JPanel(false);
namePanel.setLayout(new GridLayout(0, 1));
namePanel.add(userNameLabel);
namePanel.add(passwordLabel);
JPanel fieldPanel = new JPanel(false);
fieldPanel.setLayout(new GridLayout(0, 1));
fieldPanel.add(userNameField);
fieldPanel.add(passwordField);
connectionPanel.add(namePanel);
connectionPanel.add(fieldPanel);
if (JOptionPane.showOptionDialog(null, connectionPanel, "Clay - " + title, JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, new String[] { "Ok", "Cancel" }, "hej") != 0) {
return null;
}
return new String[] { userNameField.getText(), passwordField.getText() };
}