JLabel hostLab = new JLabel("Host");
JTextField hostTxt = new JTextField("localhost");
hostLab.setLabelFor(hostTxt);
JLabel passwordLab = new JLabel("Password");
JTextField passwordTxt = new JPasswordField("password1");
passwordLab.setLabelFor(passwordTxt);
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(4,2));
panel.add(jidLab);
panel.add(jidTxt);
panel.add(usernameLab);
panel.add(usernameTxt);
panel.add(hostLab);
panel.add(hostTxt);
panel.add(passwordLab);
panel.add(passwordTxt);
int answer = JOptionPane.showOptionDialog(frame,
panel,
"Login",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
new String[] {"Login", "Exit"},
"Login");
if(answer != 0) {
System.exit(0);
}
pcm.setUsername(usernameTxt.getText());
pcm.setHostname(hostTxt.getText());
pcm.setPassword(passwordTxt.getText());
pcm.setJID(jidTxt.getText());
}