Question

I want a jTextField that shows suggestions in a popup as the user types (like google suggests). I want suggestions data to be fetched from a database table. I have been looking at SwingX and GlazedLists but I think they provide jComboBox autocomplete, and jTextField does not show a popup in these libraries.

I want to monitor user input and re-query the database after specific intervals.

Thanks.

Was it helpful?

Solution

I would keep looking into SwingX or GlazedLists, to avoid re-inventing the wheel. But if you are doing it yourself:

Add a KeyListener to the field and show a popup just below the text field whenever the user types. The popup could just be a menu with possible items or maybe even a JList. Make sure your database query can keep up with the typing or put the work on a separate thread.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top