Another tips and Tricks for today! Whenever you have created a JFrame in NetBeans, the auto-generated code which is in sync with Matisse Builder, has a method initComponents() initially, right?
When you make a switch to the Source view, you see a collapsed section of code, with a label on it- “Generated Code”. Ever thought, how it happens.
Here’s the trick
Write code between following comments;
//<editor-fold defaultstate="$state" desc="$label"> /* Place your code over here */ //</editor-fold>
Replace $state with expanded/collapsed and $label with any name/phrase you choose. Also, replace the following;
/* Place your code over here */
with your code, it could be either inside a method, or inside a Java class, wrapping various methods, variable declarations etc.
Tips to Remember
Keep in mind that, the editor-fold tags must be inside same block of code, either inside a Java class, or inside a method! You can’t opening tag inside a Java class, and closing tag inside a method OR vice-versa!
It works in all Java classes. Also, its basic use is to categorize the sections of code. Like, you may have an editor-fold for only variable declarations, and/or for user created methods, and/or for getter/setter methods!