Stanley Mungai
Stanley Mungai

Reputation: 4150

Generate JTextField Input Guesses

I have a Swing Application with a JTextField that the user is Supposed to Input ID Numbers. The ID Numbers are Stored in a database. During Inquiry from the DB the End user is again required to Input the ID Number so as to Query the DB. I need suggestions as to what to do so that when the user Inputs the First Digits of the ID Number, Guesses appear below the JtextField for the User to Choose from. Is this Possible with Swing and what Is the Best way to Implement it?

Upvotes: 0

Views: 178

Answers (3)

L.Sankaranarayanan
L.Sankaranarayanan

Reputation: 1

You should write a PickList class which must contain a SQL Query select * from dbtableName where empId %getUserInput()%;

Upvotes: 0

mKorbel
mKorbel

Reputation: 109823

still not sure,

  • you can to use AutoCompleted JComboBox / JTextField (AFAIK ther no issues with Document, Focus, Caret and Selection/HightLighter)

  • (and to combine with a.m. point) to use filtering in JTable (with one Column and/or without JTableHeader) placed in the undecorated JDialog or JWindow(undecorated by default) in case that you want to display popup window with long list of sentences in the scrollabel contents, that could be clickable

    1. use Swing Timer (5 -10 seconds for autohide for popup window)

    2. share (use the same) model for JTable and AutoCompleted JComboBox / JTextField based on Vector or ArrayList,

    3. to check focus lifecycle (nothing better aroung) for popup window as Java Calendar by Kai Toedter (download codesource)

Upvotes: 1

basiljames
basiljames

Reputation: 4847

Try AutoCompleteDecorator in swingx. Check this post.

Upvotes: 1

Related Questions