On Tue, 7 Feb 2023 20:35:52 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>So it looks all Metal themes use MetalMenuBarUI. As such, moving the 
>registration of MenuBarUI class id from OceanTheme to MetalLookAndFeel makes 
>sense. Especially, taking into account that javadoc for MetalMenuBarUI states, 
>it “is responsible for the metal look and feel of JMenuBars.”

That class was added when the metal was updated to support the Ocean theme by 
default. So now it is kind of synonymous metal and ocean. This particular class 
provides support for the "XXX.gradient" property which is initialized by the 
Ocean theme or could be set by the application. We can initialize it as 
suggested but then we should somehow exclude the code path in it for the old 
"basic/DefaultMetalTheme" which do not use this property(like via 
MetalLookAndFeel.usingOcean())  The themes you see in the SwingSet2 other than 
Ocean are all "basic/DefaultMetalTheme" where this class is not used.

> And If I am writing a new Theme do I really have to know which UI classes are 
> always installed ? Its crazy.

No, you do not need to know that. you can subclass the DefaultMetalTheme or 
OceanTheme, or you can implement the theme from scratch by implementing the 
abstract MetalTheme. The theme in metal L&F is some kind of 
color/icons/rendering customization only. But if the new theme will require 
some custom behavior then yes it will be necessary to set a custom new 
"MenuBarUI ".

-------------

PR: https://git.openjdk.org/jdk/pull/11646

Reply via email to