To generate getters and setters, select any variable in file, select “Refactor” and then select “Encapsulate Fields…” as shown in Figure 1.1
Click Select All to create getters/setters for all fields as shown in Figure 1.2. You can choose individual fields as required.
Click Refactor. Netbeans will create the getters and setters for you.