Code Completion

"melG" <[email protected]> Tue, 28 Mar 2017 20:47:24 +0000
Newsgroups gmane.comp.java.netbeans.devel
Message-ID <[email protected]>
Hello,
I want to perform some action when a code completed.

For instance, when "toString" method completed, I will perform my action.

I've found that in "CompletionItem" class has a "defaultAction(JTextComponent component)" method which is invoked, after pressing VK_ENTER or double-clicking on that item.

http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-editor-completion/org/netbeans/spi/editor/completion/CompletionItem.html

Simply, I tried to print something to output as follows:


Code:

public class SomeCompletionItem implements CompletionItem {
   ...
   @Override
   public void defaultAction(JTextComponent component) {
      System.out.println("Code Completed.");
   }
   ...
}



But I did not anything printed. Is there something I'm missing or is there any way that I can do that?