Skip to content
Advertisement

Making a search bar in javafx

I have a code written using javafx that creates a tableview and then inserts the data given in another file. Im trying to implement a search bar. I want to be able to search the table in the gui and have the matches show up. Any direction?

Edit: i understand this question was broad, i wasn’t expecting a precise answer, I was just looking for direction.

Advertisement

Answer

Here is a sample app I altered from here.

I altered the app to filter a TableView using a ChoiceBox, TextField, and a FilteredList. The TextField's onKeyReleased does the filtering based on the ChoiceBox's current value.

Comments in the code.

JavaScript

enter image description here

Updated on 01/08/2021. It now uses the TextProperty instead of a KeyListener to set the predicate that filters the results.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement