User Narayan posted this helpful code for a TextField control in Java FX 2 to accept only numeric values.

Well, since there is no built-in class that does this functionality, the only solution was to create my own. Here is my version of an auto-complete class that can be used for a TextField or editable ComboBox.

If you want to use this for a TextField node, just change parts of the code to cater to it. It should not be hard.

To use this class, just do

Easy, right?

This class also includes an added feature wherein after you type something in the editable ComboBox and when you press the ENTER key, an action will take place: say, you want to save it to the database or something.

Note: the focus listener is now added to the ComboBox’s TextField component because in the development environment, it works fine. However, when deployed as an Applet, it does not work. Only when I shifted the focus listener to the ComboBox’s editor did it work correctly.

This is how you add an inner shadow effect to either a text field or text area in Java FX.

The sample CSS code shows an upper left sided inner shadow.

Related Posts Plugin for WordPress, Blogger...