Note: NetBeans has its own API to plug options/preferences panels. The walkthrough below leverages the INTViewer API. If you would rather use the NetBeans API, follow this tutorial instead: https://platform.netbeans.org/tutorials/74/nbm-options.html
A preference dialog is a form accessible from Tools -> Options. In this example, we will add a dialog to the "GUI Preferences" section. This walkthrough makes use of the panel component that was created in NetBeans/Swing Creating a Panel Walkthrough. If you did not follow this walkthrough, you can download this panel implementation in the attachments at the bottom of this page.
Reviewing Dependencies
The creation of a panel requires two modules that are part of the INTViewer platform:
See the list of INTViewer modules to load the INTViewer platform and for a description of each module.
This requires the import of java.awt.GridLayout, javax.swing.BorderFactory and javax.swing.JPanel.
You can download the DemoPreferencesEditor.java file from the attachments at the bottom this page.
Modify the layer.xml file as follow:
In this layer.xml file:
You can download the layer.xml file from the attachments at the bottom this page.
This class makes use of the Java Preferences API.
You can download this class from the attachments at the bottom of this page. You can prefer to use the NetBeans module preferences mechanism and change:
Preferences root = Preferences.userRoot();
to
import org.openide.util.NbPreferences;
...
Preferences root = NbPreferences.forModule(DemoPreferencesUtil.class);
Only the relevant code is show in this screen snapshot. You can download the entire class from the attachments at the bottom of this page.
You can download the final DemoPreferencesEditor.java from the attachments at the bottom of the page.
More information about Preferences Editors is available in the references.