JEditorPane Code Completion (Part 3)

Posted by Geertjan on Oracle Blogs See other posts from Oracle Blogs or by Geertjan
Published on Sat, 13 Oct 2012 10:40:41 +0000 Indexed on 2012/10/13 15:47 UTC
Read the original article Hit count: 186

Filed under:

The final step is to put an object into the Lookup on key listening in each of the JEditorPanes, e.g., a "City" object for the CityEditorPane and a "Country" object for the CountryEditorPane. Then, within the CompletionProviders, only add items to the CompletionResultSet if the object of interest is in the Lookup.

The result is that you can then have different code completions in different JEditorPanes, as shown below:


I've also included the Tools | Options | Editor | Code Completion tab, so that the code completion can be customized.

The full source code for the example is here:

java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.2/misc/CustomerApp

© Oracle Blogs or respective owner

Related posts about /NetBeans IDE