java - JavaFX 2.2 TextField maxlength -


i working javafx 2.2 project , have problem using textfield control. want limit characters users enter each textfield can't find property or maxlength. same problem existing swing , solved this way. how solve javafx 2.2?

this better way job on generic text field:

public static void addtextlimiter(final textfield tf, final int maxlength) {     tf.textproperty().addlistener(new changelistener<string>() {         @override         public void changed(final observablevalue<? extends string> ov, final string oldvalue, final string newvalue) {             if (tf.gettext().length() > maxlength) {                 string s = tf.gettext().substring(0, maxlength);                 tf.settext(s);             }         }     }); } 

works perfectly, except undo bug.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -