Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34693
| From | Tassilo Horn <tsdh@gnu.org> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: JavaFX: Bindings, StringConverters, and ChangeListeners |
| Date | 2016-06-23 08:39 +0200 |
| Organization | University Koblenz-Landau Campus Koblenz |
| Message-ID | <877fdgl87c.fsf@gnu.org> (permalink) |
| References | <87wplhbbvy.fsf@gnu.org> <dsvl9oFqvv4U1@mid.individual.net> |
Nigel Wade <nmw@ion.le.ac.uk> writes: Hi Nigel, > The first thing I'd suggest is to think about the problem from the > user's perspective rather than the programmer's. > > If I, as a user, enter a number into a text field and inadvertently > enter an invalid character, I'd be rather annoyed if the GUI element > wiped out what I'd entered and replaced it with something which I > didn't want. It would be better from my (user) perspective if the > text element warned me of my transgression (flash, highlight, red > background whatever) and left my text there for me to edit, rather > than make me enter it again with the likelihood of making a similar > mistake again. Oh, flashing is actually a nice idea and can be done pretty easily from my listener. > Imagine if the current contents were 002324561234, and I wanted to > change it to 002324560234 but instead changed it to 00232456O234. Your > current method would revert it back to 002324561234, and I may never > notice that my change had been overridden. Well, in the concrete case the number is the maximum number of matches to be looked for in a database, so the numbers aren't that hard to distinguish but I got your point. > What's wrong with parsing the entered text and, if there is an > exception, catch it and display some feedback, leaving the focus on > the text field? If you really, really want to set the text back to the > original value you could still do that in the catch block. I don't see > any benefit from using a ChangeListener. The problem is that I have no control over when and where the string in the text field is parsed and converted to a number. I just specified a declarative binding between the text field's text property and an integer property with a standart converter and thereby gave up exact control over these things. But bindings are such an integral part of FX that I guessed there must be some standart way to treat invalid input so that the binding's converter doesn't err. Bye, Tassilo
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
JavaFX: Bindings, StringConverters, and ChangeListeners Tassilo Horn <tsdh@gnu.org> - 2016-06-22 15:18 +0200
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Nigel Wade <nmw@ion.le.ac.uk> - 2016-06-22 15:22 +0100
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Tassilo Horn <tsdh@gnu.org> - 2016-06-23 08:39 +0200
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Martin Gregorie <martin@address-in-sig.invalid> - 2016-06-23 09:59 +0000
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Nigel Wade <nmw@ion.le.ac.uk> - 2016-06-23 12:19 +0100
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Nigel Wade <nmw@ion.le.ac.uk> - 2016-06-23 12:39 +0100
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Tassilo Horn <tsdh@gnu.org> - 2016-06-23 14:39 +0200
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Eric Douglas <e.d.programmer@gmail.com> - 2016-06-22 08:06 -0700
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Tassilo Horn <tsdh@gnu.org> - 2016-06-23 08:45 +0200
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Eric Douglas <e.d.programmer@gmail.com> - 2016-06-23 05:11 -0700
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-23 08:22 -0400
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Tassilo Horn <tsdh@gnu.org> - 2016-06-23 15:12 +0200
Re: JavaFX: Bindings, StringConverters, and ChangeListeners Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-23 10:56 -0400
csiph-web