aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes creating a record index? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "creating a record index?" Watch "creating a record index?" New topic
Author

creating a record index?

darren malt
Greenhorn

Joined: Aug 17, 2002
Posts: 23
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.


"Know where I can get a compiler with a sense of humour?"
San Su
Ranch Hand

Joined: Jul 06, 2001
Posts: 313
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.
darren malt
Greenhorn

Joined: Aug 17, 2002
Posts: 23
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...
San Su
Ranch Hand

Joined: Jul 06, 2001
Posts: 313
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 ]
Sri Rangan
Ranch Hand

Joined: Dec 08, 2001
Posts: 160
Here is another example code:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating a record index?