Example Code Dialog

Here is the code that creates the above dialog:

Example #1

 /**
 * The new default dialog class must be derived from DefaultNodeSettingsPane.
 */
public class DemoNodeDialogPane extends DefaultNodeSettingsPane {
 
    /**
     * Instantiate and add all needed components here in the constructor.
     * (The suppress warnings is used to avoid compiler warnings from the
     * constructor with generic varargs.)
     */
    @SuppressWarnings("unchecked")
    DemoNodeDialogPane() {
        // following components are bordered
        createNewGroup("Group 1:"); 
        addDialogComponent(new DialogComponentString(new SettingsModelString(
                DemoNodeModel.STR, null), "Enter a string value:"));
        addDialogComponent(new DialogComponentNumber(new SettingsModelInteger(
                DemoNodeModel.INT, 3), "Enter an integer (1-17):", 1));
        addDialogComponent(new DialogComponentNumber(new SettingsModelDouble(
                DemoNodeModel.DBL, 3.0),
                "Enter a floating point number:", 0.1));
        // closes the prev group, opens a new one>
        createNewGroup("Group 2:"); 
        addDialogComponent(new DialogComponentBoolean(new SettingsModelBoolean(
                DemoNodeModel.BOOL, false), "Checkit or leave it:"));
        addDialogComponent(new DialogComponentStringSelection(
                new SettingsModelString(DemoNodeModel.STRSEL, null),
                "Your choice:", "First", "Second", "Third"));
        closeCurrentGroup();
        addDialogComponent(new DialogComponentColumnNameSelection(
                new SettingsModelString(DemoNodeModel.COLSEL, ""),
                "Select a column", 0, true, IntValue.class, DoubleValue.class));
    }
}

This code adds 6 components grouped by two borders. All components following the createNewGroup(

command will be put into the frame. The next createNewGroup command closes the previous group and opens a new one. If you want to add components below the last border, you can use closeCurrentGroup. Components added after this command will be placed outside any border.

Each component's constructor requires a new instance of a SettingsModel. The settings model expects a string identifier that it uses to store and load the value of the component, and a default value which it holds until a new value is loaded. Additional parameters are necessary, depending on the type of component (most require a string) that will be displayed in front of the component as label. For more details, please refer to the documentation on the specific component.

LinkedInTwitterShare