How to add suggestion list to JEditorPane
How to add suggestion list ( when user type part of some word to suggest list of all tokens which 开发者_如何学编程starts with that part, something like intellisense in Eclipse ) to JEditorPane ? I have implemented method which returns ArrayList of strings but how to show that ?
add them to a JList and show the list in a JPopupMenu
javax.swing.JPopupMenu may help u...
for every keyReleasedEvent pass the substring to your method..
for each suggested string javax.swing.AbstractAction should be created..
I hope it helps...
I would advise you to use the open source Jide common layer, particularly the AutoCompletion helper class.
It works with a lot of swing components, with or without a list of possibilities being shown. Highly recommended.
精彩评论