java - jTextField loses focus on typing -
i trying put lost focus
listener on jtextfield. however, function triggered when typing in text field.
one possible way, in opinion, start timer when focus lost. however, not sure if right way go.
any leads?
import java.awt.event.focusevent; import java.awt.event.focuslistener; import javax.swing.jtextfield; public class main { public static void main(string args[]) { final jtextfield textfield = new jtextfield(); textfield.addfocuslistener(new focuslistener() { @override public void focusgained(focusevent e) { //your code here } @override public void focuslost(focusevent e) { joptionpane.showmessagedialog(null, "focus lost"); } }); } }
Comments
Post a Comment