java - How perform task on javaFX TextField at onfocus and outfocus? -


i working on javafx project. need perform task on javafx textfield.

for example on "on focus" event textfield want print

system.out.println("textfield on focus"); 

and on "out focus" event should print

system.out.println("textfield out focus"); 

i thought might helpful see example specifies changelistener anonymous inner class scottb mentioned.

textfield yourtextfield = new textfield(); yourtextfield.focusedproperty().addlistener(new changelistener<boolean>() {     @override     public void changed(observablevalue<? extends boolean> arg0, boolean oldpropertyvalue, boolean newpropertyvalue)     {         if (newpropertyvalue)         {             system.out.println("textfield on focus");         }         else         {             system.out.println("textfield out focus");         }     } }); 

i hope answer helpful!


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -