I've a list of 'people' displayed in a JTable and stored in a database. I'd quite like users to have the results narrowed in that table as they type into a search area.
So for example typing 'S' would narrow the displayed names to 'Susan', 'Stephen', 'Steve', which would be narrowed down to just 'Susan' as soon as you type 'Su'
I was thinking of using the DocumentListener methods .removeUpdate(e)
and .insertUpdate(e)
to call the method that searches the underlying database and updates the table view - but this seems pretty wasteful.
In effect I'd be creating a new database connection, and other db objects, and refreshing the table every time any character was typed. I'm not sure if this is just poor design, or something that will actively cause me problems? Is there a better way of approaching this? or should I just stick to a normal search button?