Changing the visibility of form components at runtime

One of the strong points of form screens is that they are displayed by console installers without any further configuration. You don’t have to program the user interface twice, once for the GUI and once for the console.

However, it is often necessary to hide certain form components at runtime. For example, a certain form component might only make sense on a specific platform. Until now, you could use the initialization script of the form component to change the visibility like this:

boolean visible = Util.isWindows();

This hides the form component unless the operating system is Windows.

However, the drawback of this method is that the console installer does not execute the initialization script of a form component – there is no GUI widget created and so the configurationObject parameter would be null. In the upcoming install4j 4.2.3, we have added a visibility script property that works for both the GUI and the console installer:

Even simpler than the previous initialization script, a simple visibility expression of


(no semicolon at the end to make it an expression rather than a script) hides the form component on non-Windows platforms.