Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing TextField value without triggering TextListener

I have a TextListener I want to change programatically without triggering its TextListener. I just want the text listener to activate on user text changing. How should I proceed ?

TextField human = new TextField();
human.addTextListener(myListener);

// I don't want this line to trigger listener
human.setText(myString);
like image 330
sinsedrix Avatar asked Oct 23 '25 15:10

sinsedrix


1 Answers

You could remove and re-add the listener or give it a boolean to toggle when it should listen.

Edit: per Tom Hawtin: the second recommendation, the one to use a flag, is much preferred over adding/removing a listener, and this makes sense to me as well.

like image 73
Hovercraft Full Of Eels Avatar answered Oct 26 '25 05:10

Hovercraft Full Of Eels



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!