In NetBeans you can hide code in editor folds. Just put the code you would like to hide in between comments of the form:
//<editor-fold defaultstate="collapsed" desc="comment">
//</editor-fold>
For example, I use this to automatically hide code with sensitive information when screen casting, giving presentations, or the like. This way the code is still functional, but I can only expose the parts that are important to the discussion.
//<editor-fold defaultstate="collapsed" desc="API-KEY">
private static final String API_KEY = "Not to be shared";
//</editor-fold>
You can also add a fold by selecting the code you wish to hide with the mouse. A light bulb icon will appear in the editor's margin. Click the light bulb and pick
Surround with //<editor-fold defaultstate="collapsed" desc="comment">...
to have the editor add the needed comments for you.