Is there a good place to stick startup code for a NetBeans Platform app? What I’ve been doing as a work around is have each of my TopComponents instantiate my App class if it has not been instantiated already. Seems kind of tedious. I found this in an online tutorial but was wondering if someone knew of a better approach.
public class Installer extends ModuleInstall {
@Override
public void restored() {
// By default, do nothing.
// Put your startup code here.
}
}
Doing some one-time initialization (or shutdown operation) for a complete module is indeed best done in the ModuleInstaller.
At least it works fine for me.
I use it mainly to make sure OpenOffice that might or might not be started due to a user action from within my module is shutdown cleanly.