2
I got the following JOptionPane
:
As you can see the focus is on the Cancel maestro option
I need this focus to be on OK, but I have no idea how to do that. My code:
JPanel panel = new JPanel();
JLabel label = new JLabel("Digite a senha para iniciar o auxilio:");
JPasswordField pass = new JPasswordField(10);
panel.add(label);
panel.add(pass);
String[] options = new String[]{"OK", "Cancelar maestro"};
int option = JOptionPane.showOptionDialog(null, panel, "Inicio de auxilio",
JOptionPane.PLAIN_MESSAGE, JOptionPane.NO_OPTION,
null, options, options[1]);
if (option == 0) {
...
}...
Someone could guide me?
and if I want the focus to be in the password field?
– Vinicius Leonardo
@Viniciusleonardo change the initialValue for
null
that the focus goes to the text field.– user28595