开发者

JKeyListener chars / auto complete

I want to make an开发者_开发问答 auto completion textfield, which replaces the input with the first hit and selects the part which wasn't entered by the keyboard yet. To do so, I'll have to count the chars typed (or deleted). How can I filter if the KeyEvent is a printable Char (and not SHIFT f.e.)?


Look at https://swingx.dev.java.net/ This lib is already have great autocomplete text fields


i prefer to do it with the KeyListener

Well, a KeyListener is the wrong tool for the job.

If you really want to write your own code then you should start with a DocumentListener. Every time text is added or removed from the text field you will be notified. Then you can implement your auto completion code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜