Home > Java > Cool Netbeans trick

Cool Netbeans trick

May 27th, 2005

Say you write an overly large chunk of code that you want to apply some code folding to, say 5 methods in your class that you want to get out of the way so no-one edits them. There is a method to do this. Normally, NetBeans would simply allow you to fold each method, but this still shows the methods. Here is a trick for forcing a fold for all 5 methods.

// <editor-fold defaultstate="collapsed"
             desc="hidden methods - don't edit">
         public method1 {}
         public method2 {}
         public method3 {}
         ...
// </editor>

When you open the class in NetBeans, all you methods will be nicely hidden behind a single fold with the message “hidden methods – don’t edit”. Cool, eh?

Categories: Java Tags:
Comments are closed.