Path: csiph.com!news.swapon.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!cache.uni-koblenz.de!not-for-mail From: Tassilo Horn Newsgroups: comp.lang.java.programmer Subject: Re: JavaFX: Bindings, StringConverters, and ChangeListeners Date: Thu, 23 Jun 2016 08:45:39 +0200 Organization: University Koblenz-Landau Campus Koblenz Lines: 34 Message-ID: <8737o4l7xo.fsf@gnu.org> References: <87wplhbbvy.fsf@gnu.org> NNTP-Posting-Host: j289989.servers.jiffybox.net Mime-Version: 1.0 Content-Type: text/plain X-Trace: cache.uni-koblenz.de 1466664339 15634 134.119.24.195 (23 Jun 2016 06:45:39 GMT) X-Complaints-To: news@cache.uni-koblenz.de NNTP-Posting-Date: Thu, 23 Jun 2016 06:45:39 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:BkBN3yh1hdgTZJ2OMKVO+zimsLk= Xref: csiph.com comp.lang.java.programmer:34694 Eric Douglas writes: Hi Eric, >> To prevent the user from entering invalid input, the textProperty() >> also has a ChangeListener that resets to the old value in case the >> new value cannot be parsed to an Integer. > > Revert to old value? Revert to old value in this case basically means the user types a key and the value does not change. > You don't want a user to be able to type something and see what they > typed then change it on them. Well, I think in this case it's not too bad, especially if the field flashes when invalid input is entered. > I don't know much about Java FX, I write Swing and have only needed > the FX for the WebView, but for a numeric entry allowing only valid > numbers I've used JTextField with a custom input filter. The input > filters process every character they try to add to or remove from the > control before adding or removing it. Yes, that's what I did in Swing, too. And the FX ChangeListeners are not too different. At least, they are called on any key the user typed into the text field. My problem is more on the part on when the binding's string-to-integer converter is invoked. When entering text in the middle or end, it'll be called after my listener (good!) but when entering text at the front, it'll be called before my listener (bad!). Bye, Tassilo