Forums Register Login

creating a record index?

+Pie Number of slices to send: Send
hi ya guys, hope you can give me some help here.
I am trying to create a searchable index, with a textfield at the top where you enter the record name, and a scrollable panel below that shows an alphabetical list of the record names.
no problem.
However, I want the record list to automaticaly set focus to the appropriate record name as you enter the name you are searching for,(like you have in a help topic index, for example).
So if I type the letter 'd' in the textField, the first record that begins with a d in the index is highlighted. then if I type an 'a', if there is a record name starting with "da", then this will be highlighted.
If you have any ideas on how I can go about the automatic highlight, I'd love to hear them as I don't have a clue at the moment.
Thanks.
+Pie Number of slices to send: Send
One solution I can think of is, store all the names in an array and whenever user types the word, search the particial word in the array. Get the index if you find one and select the corresponding record in the table. I did something similar for our project couple of years ago (autocomplete in ComboBox). I used binarysearch to search the text in the array. I dont have the code rightnow, but if you need it, let me know. I will search for it.
+Pie Number of slices to send: Send
Sankar, if you wouldn't mind sending me that code I would appreciate it. I'm currently using the same kind of system as you said in your reply, and I THINK (hope) I'm getting there although it's always nice to see how someone else done it. I'm sure I will learn from it as I am quite new to AWT/swing.
thanks for the reply.
Daz...
+Pie Number of slices to send: Send
darren,
The file is too big, so I am posting the code piece of codes related to this functionality..
BinarySearch. It takes the partical string as key and search the key in the array.


This code is there in editor's setDocument method. It looks for unselected text value in the textfield and adds the newly typed key and search it in the array.

Please let me know if you need more information.
[ October 28, 2002: Message edited by: Sankar Subbiah ]
+Pie Number of slices to send: Send
Here is another example code:
I need a new interior decorator. This tiny ad just painted every room in my house purple.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1204 times.
Similar Threads
textbox to listbox(simple)
Reading in the FIle
JFileChooser not saving input file name
Unsolved Programming Problem. Need Help.
How to format a textfield to accept different data types?!!
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:04:12.