Thanks Neil, I have the FlatLaf modules already installed when compiled. I 
found that Installer's validate() may not return the correct LAF that will 
actually be used. i.e. In validate(), UIManager.getLookAndFeel() may return 
Metal and then go on to a later stage where it will actually become Windows (or 
whatever). 
Anyway, I managed to achieve what I wanted but I'm not sure if I'm just lucky 
for now and at some point this won't work due to some async nature of NB 
startup, now or in a future version of NB.
Basically, in every module that is likely used early or may do anything 
significant in rendering the GUI (TopComponents), I included an Installer 
module where I override restored(). It seems that by the time any Installer's 
restored() is called, the actual LAF has been chosen by NB (not true in 
validate() as mentioned above). So, the first statement in each restored() 
calls MyUiSettings.init(). This init() is synchronized and is latched to be 
performed only once by first caller.init() checks the current LAF using 
UIManager.getLookAndFeel(). If it's not a FlatLaf type, then 
UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf") is called followed 
by NbPreferences.root().node("laf").put("laf", 
"com.formdev.flatlaf.FlatLightLaf").
As I said, it seems to work although it doesn't feel ideal.        

    On Wednesday, August 31, 2022 at 03:08:35 PM GMT+3, Neil C Smith 
<neilcsm...@apache.org> wrote:  
 
 On Wed, 31 Aug 2022 at 12:30, Mike Hallan <mkhal...@yahoo.com.invalid> wrote:
> Sounds like there is no simple or non-brittle way to do this. Thanks anyway.

You might also look at configuring the installed look and feels -
https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/UIManager.html#setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo%5B%5D)

The NetBeans UI is just showing the installed look and feels.  Or you
could hide the existing UI selection and provide your own.

You should be able to validate and change the LAF preference during startup too.

Both should probably happen in a ModuleInstall validate method that
runs after this one -
https://github.com/apache/netbeans/blob/master/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/Installer.java#L35

Neil
  

Reply via email to