Updated: AutoFill TextBox with FilterMode in Javafx 2.0 (Custom Control)

Updated on Dec 4, 2014: Published in Maven Repository javafx-autocomplete-field
Updated on Aug 5, 2014: Fixed code for JavaFX 8 [Github Repo]

Hello After working some couple of days on Javafx 2.0 Custom Control. I came to the final result of my Custom Control. The Custom Control which I’m going to tell you is about “Auto-Fill TextBox” . This control consists of two major controls they are TextBox and ListView with a Popup where Listview is embedded.

Features of this textbox

  1. AutoFill Textbox on item selection with keys.
  2. Filter Mode

Let’s start these features one by one. To start using this control you can first download the Jar package or see Documentation first.

How to get Started

First download the jar file ‘AutoFillTextBox.jar’ from here. Then add the jar file to the Library of your current JavaFX Project where you want to implement this control. (PLEASE ADD jfxrt.jar ALSO TO YOUR PROJECT LIBRARY).

Now Let’s start the coding phase . On coding we’ll be working with the features presented in TextBox.

1. AutoFill Textbox on item selection with keys.

CSS(control.css)

Output

AutoFill TextBox

 

 

2. Filter Mode

You can easily set the Filter Mode on/off  by using setFilterMode(boolean filter) . Let’s see the example of this FilterMode.

CSS is just same as of previous example
Output:

FilterMode on AutoFillTextBox usage

 

Thanks for watching this blog. If you have any queries then please comment without hesitation.

Have a šŸ™‚ good day.

For changelog you can see at top of the post

121 thoughts on “Updated: AutoFill TextBox with FilterMode in Javafx 2.0 (Custom Control)”

  1. Hi, I try to use your AutoFillTextBox in my application but i have a problem.

    When i pressed a key like (‘a’ for example), the textfield auto select aplogize in the list. If i pressed ‘au’ the items on the list are good (just auto) but the textfield was autocompleted by ‘aplogize’.

    do have an idea ?

    I don’t know where the probleme is and i would like a textField no autocompleted with a listview filtered.

    thx Maxime.

  2. The same problem I faced like Maxime and next is when I press back button, then text will not be deleted completely. I tried setFilterMode () method also but I didn’t get a proper auto compete text field how can I do

  3. Pingback: AutoComplete ComboBox in JavaFX - BlogoSfera

  4. Hi i have issue as
    java.lang.NoSuchMethodError: com.sun.javafx.scene.control.behavior.BehaviorBase.(Ljavafx/scene/control/Control;)V

    at np.com.ngopal.control.AutoFillTextBoxBehavior.(AutoFillTextBoxBehavior.java:14)
    and 14 line is

    public AutoFillTextBoxBehavior(AutoFillTextBox textBox) {
    super(textBox);
    }

  5. Hi,

    I tried to use your jar the same way you described it in “2. Filter mode”.
    However, when I write down a letter, it automatically writes the first element of the list in the search box. Is there any way to turn that off?
    Moreover, if I try to delete a research I made form the box, I will not work either..
    You jar is sick and would be perfect for my app but I cannot manage to make it work properly… That’s very frustrating.

    Thank you in advance!

  6. Hey,
    got a nullpointer at line 382 in AutoFIllTextBoxSkin when you start you input with space.

    you have to check first if listView.getItems() != null

    if (listview.getItems() != null && listview.getItems().containsAll(list)
    && listview.getItems().size() == list.size())

    fix’d it for me

  7. Hi, I tried to change the size of the TextBox because it’s too small but it didn’t work, how can I do that?

  8. Hi Mr. Narayan G. Maharjan,

    Can this be integrated with the SCENE BUILDER? if so can you show us how.

    Hoping for your reply.

    Thank you.

  9. Thank you for you’re reply Mr. Narayan G. Maharjan,

    Iv’e already added the jar in the scene builder and in the project library what i’m confused with is how to include the initialization of the:

    final AutoFillTextBox box = new AutoFillTextBox(data);
    to
    Parent root = FXMLLoader.load(getClass().getResource(“Login.fxml”));

    What i’m trying to do is when the user types in the login text box it shows the suggested username.

    I’m very sorry, i’m still new to java/javafx. Hope that you can help me understand how to use your code. šŸ™‚

    Thank you in advance.

  10. Hi got it to work in scene builder by following your “TEST” Project folder with the source code and as what iv’e read in the comments the same problem does occur when typing a keyword it automatically suggest that word then when pressing backspace the program produces an error.

    Do you have any work around with this?

    Thanks in advance. Great work btw. šŸ˜€

  11. Hi.
    I want to use JfxTextfield instead of AutoFillTextBox because I like the skin of jfxTextfiled and I want to have this in my project. Also I want to change the skin of AutoFillTextBox. How can I do these jobs?

    Thanks

  12. Pingback: Java desktop links of the week, August 15 – Jonathan Giles

Leave a Reply