Skip to content
Advertisement

Setting the Color of the Title Bar with Netbeans Platform Application (FlatLaF)

I’m currently working on a Netbeans Platform application that uses com.formdev.flatlaf.FlatLightLaf as the Look and Feel. The application is using Java 11 and running under Windows 10.

I would now like to change the color of the TitlePane. Changing the color of specific elements (like jPanels etc.) globally for the entire application can be done by changing properties within the UIManager. So I tried changing many of the background-color specific settings from UIManager.getDefaults() as well as UIManager.getLookAndFeelDefaults(). For example changing the TitlePane.background property to something like UIManager.put("TitlePane.background", new ColorUIResource(100, 100, 100));. However none of the dozens of properties I changed worked at all.

The color can be changed though as evidenced by the changed color of the TitlePane when using the com.formdev.flatlaf.FlatDarkLaf (darkmode).

If anyone has any idea which properties need to be changed in order to change the color of the title pane in a Netbeans Platform application I would very much appreciate any form of help!

Advertisement

Answer

I believe I found the culprit. In a recent release of Netbeans the option to set “TitlePane.unifiedBackground” for FlatLaF was introduced. However when setting UIManager.put("TitlePane.unifiedBackground", true); the problem described above will occur and I effectively can’t set the background color of the TitlePane.

As seen in the method updateUnifiedBackground() of class FlatLFCustoms(https://github.com/apache/netbeans/blob/12.4/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java) in the Netbeans source code, the color of the titlePane should be set by adjusting the property “Panel.background”. This however doesn’t seem to work properly.

A workaround seems to be to set UIManager.put("TitlePane.unifiedBackground", false); and then just set the “TitlePane.background” to the desired color. If you still want the unified TitlePane look you can achieve that by also setting “Panel.background” and “Toolbar.background” to the same color.

In effect this will look identical to setting the unifiedBackground for the TitlePane only now you can change the color. Hope this helps someone who stumbles upon the same Problem.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement