
September 15th, 2002
|
|
search entry history I'd like to see a feature like the thingy in IE which when you start typing in a text box it shows a drop down list of previous entries that match what you have entered previously. I constantly type the same searches into limewire (e.g. rare music that only occasionally gets results) and i'm lazy.
It might be a bit tricky in Java though to get the drop down. It should be fairly easy to display previous entries 'in-line' however. I've had a quick peek at some of the code and I think the following approach should work.
Instead of using standard JTextField's, limewire would use a new class JTextHistoryField (or some other name). This would extend JTextField, but in the constructor add couple of listeners (Key and Action ?) to itself. When a character is typed:
- key event fired ?
- lookup current text in some data structure which may potentially use String.startsWith()
- if match setText() of itself to that entry.
It would be nice too if it selected or highlighted only the text that wasn't typed, and it kept the cursor in the correct place. (Is this how a similar approach to how a password field masks the input?). When an action event is recieved add the contents to the history data structure.
The data structure could possibly be held statically / singleton as you would probably want to use all history on all text boxes. It would prossibly be a SortedSet? I'm not sure how the persistence of the history data between sessions could be accomplished in limewire though.
Would also be nice to have this an optional feature and also to be able to manually clear out the history / delete specific entries.
Any thoughts ? I wouldn't mind having a crack at this if it seems like a good idea to others, although my swing is a bit rusty.
Sorry if this is the wrong group.
Thanks for a great product guys... |