Reputation: 249
I would like to have a focus listener but the way I did it shows error in IDE. My code follows
txtField.addFocusListener(event ->{
@Override
public void focus() {
System.out.println("Focus");
}
});
Can you tell me what I am making wrong?
Upvotes: 1
Views: 498
Reputation: 10633
You are mixing up Java 6 and Java 8 syntaxes. You should just write
txtField.addFocusListener(event -> {
System.out.println("Focus");
});
Upvotes: 3