By Geertjan-Oracle on Oct 13, 2012
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: