I would like to implement one of the fanciest features I every now and then. I would like to allow a user to click on a JList and if words are typed, do a query and advance the caret to the next match (prefix). Is there and example of such an implementation in Java somewhere? I'm thinking a combination of key listeners, getNextMatch() and setSelectValue().
+1
A:
I suggest you take a look at glazed lists, or other implementations of completion in java/Swing.
Riduidel
2010-03-30 12:59:32
+1
A:
JXList of Swinglabs has the exact same thing you are looking for
Try :
ring bearer
2010-03-30 13:05:06
I looked at the demo and it has an example of what I need. Thank you for your suggestion. It seems that the magic ingredient is AutoCompleteDecorator.decorate(...). However, there seems to be a problem with this example as it becomes "sticky". If you type something, it goes to the right place, but then it stays "blocked", or loses focus. I need to click on the list to make work again. What goes wrong there?
alex
2010-03-31 15:30:10
@alex I do not see the behavior you mentioned. I tried the demos using java version "1.6.0_17" of Java and focus remains on the List, and lets me continue with typing something else and the highlighter moves on to matching text.
ring bearer
2010-03-31 15:54:10
Weird, but I think I understand why. I use 1.6.0_17 and when you type on the jList everything is fine, however if you type on the text field it doesn't clear. So essentially it keeps adding letters to the previous match, however such a new word doesn't exist and so it doesn't move. If you clear the previous input with backspace it works. I plan to hide the text field anyways...
alex
2010-04-01 13:12:00
The behavior on text box is not a bug. I think it is a matter of "taste" how you wish the UI to behave. For me the behavior of that text box looks natural; but you seems to have some different expectations, which might be perfectly valid.
ring bearer
2010-04-01 14:55:46