1
I need to click on Wipe Button on the Login screen the CPF and Password the cursor goes back to the CPF field.
JFormattedTextField ftUsuario = new JFormattedTextField();
try {
MaskFormatter formatter;
formatter = new MaskFormatter("###.###.###-##");
formatter.setPlaceholderCharacter('#');
ftUsuario = new JFormattedTextField(formatter);
} catch (Exception e1) {
JOptionPane.showMessageDialog(null, "Informe o seu CPF", "Aviso!", JOptionPane.INFORMATION_MESSAGE);
}
JButton btnLimpar = new JButton("Limpar");
btnLimpar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
pfSenha.setText(null);
ftUsuario.requestFocus(); // AQUI É EXIBIDO O ERRO...
}
});
And what problem are you facing?
– user28595
ftUsuario.requestFocus(); says: Local Variable ftUsuario defined in an enclosing Scope must be final or effectively final.
– Júnior
If it is set with FINAL it gives error in another field...
– Júnior
Then change the field scope to class level. If it is local scope (within the method), to call in anonymous class only if it is final.
– user28595
If I go to 'Expose Component' and set public or Protect the error disappears but even clicking Clear the cursor does not return to the CPF field.
– Júnior