Path: csiph.com!2.us.feeder.erje.net!feeder.erje.net!2.eu.feeder.erje.net!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 15:12:33 +0200 Organization: University Koblenz-Landau Campus Koblenz Lines: 28 Message-ID: <87twgkjbge.fsf@gnu.org> References: <87wplhbbvy.fsf@gnu.org> <8737o4l7xo.fsf@gnu.org> NNTP-Posting-Host: j289989.servers.jiffybox.net Mime-Version: 1.0 Content-Type: text/plain X-Trace: cache.uni-koblenz.de 1466687553 15634 134.119.24.195 (23 Jun 2016 13:12:33 GMT) X-Complaints-To: news@cache.uni-koblenz.de NNTP-Posting-Date: Thu, 23 Jun 2016 13:12:33 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:bhHh5guJQbLAKVeO1PF0RMmrbJE= Xref: csiph.com comp.lang.java.programmer:34702 Eric Sosman writes: > FWIW, in Swing applications I've had good experiences with using > an InputVerifier. Yes, that works fine in Swing... > I'm not FXliterate, so I don't know whether there's an analog. > Could be worth a look, though. ... but there doesn't seem to be something similar in FX. Googling suggests that input validation is currently one the missing pieces in FX and it seems that right now everybody uses a FocusListener to validate the input when the control loses focus. Well, never mind, I've simply stopped using a bidirectional binding with a number-string-converter and just use maxTreffer.bind(Bindings.createIntegerBinding(() -> { String txt = txtMaxTreffer.getText(); try { return Integer.valueOf(txt); } catch(NumberFormatException ignored) { } return maxTreffer.get(); }, txtMaxTreffer.textProperty())); Thanks for all suggestions, Tassilo