Changing the visibility of form components at runtime
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(); component.setVisible(visible);
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
Util.isWindows()(no semicolon at the end to make it an expression rather than a script) hides the form component on non-Windows platforms.