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?

- 109,525
- 20
- 134
- 319

- 4,044
- 30
- 100
- 168
-
Have you done some research on that already? What was the outcome if so? – Fildor Sep 20 '12 at 11:13
-
Fildor: I would not have asked if I had a solution to it or hadn't serached around and found a solution. It is Ok if you do not want to help. I asked for Ideas Not COdes. – Stanley Mungai Sep 20 '12 at 11:15
-
2This thread may be helpful: http://stackoverflow.com/questions/1216357/drop-down-list-within-jtextfield – fish47 Sep 20 '12 at 11:17
-
I just do not want to tell you "Look there and there" if you have done so already. It always helps a lot to know what the op has already found promising but NOT solving his problem. – Fildor Sep 20 '12 at 11:17
-
@Stanley for why reason is value saved to DB and then distributes from DB back to GUI, nothing against your thread nor about description ... – mKorbel Sep 20 '12 at 11:21
-
mKorbel I need to make it easier for the End user while Querying the DB for Information to Input just a few Characters and the Closest GUess is shown on the GUI for them to select. – Stanley Mungai Sep 20 '12 at 11:26
-
@Stanley Have you checked out the link in my answer? If it is not what you need, please leave a comment in the answer as to why it is not. Then I can see if I can come up with something different. – Fildor Sep 20 '12 at 11:29
-
@Fildor, Yes I have I think it is Talking more of Jcombobox that JTextField. – Stanley Mungai Sep 20 '12 at 11:38
-
I see. So making it a JComboBox is not an option. Then check out the SO link in fish47's comment. It is a solution with JTextField but a little less sophisticated. – Fildor Sep 20 '12 at 11:46
4 Answers
http://www.orbital-computer.de/JComboBox/ Maybe this helps. I know I shouldn't post just a link. But I cannot write everything explained there again here.

- 14,510
- 4
- 35
- 67
still not sure,
you can to use AutoCompleted JComboBox / JTextField (AFAIK ther no issues with
Document
,Focus
,Caret
andSelection/HightLighter
)(and to combine with a.m. point) to use filtering in JTable (with one
Column
and/or withoutJTableHeader
) placed in the undecoratedJDialog
orJWindow
(undecorated by default) in case that you want to display popup window with long list of sentences in the scrollabel contents, that could be clickableuse Swing Timer (5 -10 seconds for autohide for popup window)
share (use the same) model for
JTable
andAutoCompleted JComboBox / JTextField
based onVector
orArrayList
,to check focus lifecycle (nothing better aroung) for popup window as Java Calendar by Kai Toedter (download codesource)
You should write a PickList class which must contain a SQL Query select * from dbtableName where empId %getUserInput()%;