Is there a java event for JTextField do like :
if the cursor already was in the JTextField and MousePressed = do nothing
if click on the JTextField for the first time = do things
I have been used , MousePressed(java.awt.event.MouseEvent evt)
but this not exactly what I want.
thank you
CodePudding user response:
You can implement your own custom logic:
- Store a "flag" like global boolean variable:
boolean alreadyClicked = false
- Each time you click the JTextField check (and toggle) that variable:
if(!alreadyClicked) { alreadyClicked = true; // do your work }
- When focusing out from that field toggle variable again to:
alreadyClicked = false;