RFR: 6513512: MetalLookAndFeel.initClassDefaults does not install an entry for MetalMenuBarUI [v3]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Mon Jan 9 10:16:57 UTC 2023
On Thu, 29 Dec 2022 06:22:01 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> Spec for [MetalLookAndFeel](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java#L247)
>> says:
>> "...MetalLookAndFeel registers an entry for each of the classes
>> in the package javax.swing.plaf.metal that are named MetalXXXUI.
>> The string XXX is one of Swing's uiClassIDs. For the uiClassIDs
>> that do not have a class in metal, the corresponding class in
>> javax.swing.plaf.basic is used. For example, metal does not
>> have a class named "MetalColorChooserUI", as such,
>> javax.swing.plaf.basic.BasicColorChooserUI is used".
>>
>> There is class MetalMenuBarUI, but the method populates given defaults table with the value
>> "javax.swing.plaf.basic.BasicMenuBarUI".
>>
>> Added entry for MetalMenuBarUI..
>> CI tests including JCK tests are ok.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>
> Spec update
> We need to clarify here what we want before the CSR can be completed. One comment in the draft CSR got my attention -
>
> "MetalMenuBarUI entry is not registered in this method although is is part of javax.swing.plaf.metal since it is registered in OceanTheme class, which is used by MetalLookAndFeel by default."
>
> Hmm .. so now I'm wondering if we are phrasing things correctly. If themes register the UIs they use why does this method do _anything_ ? Or is there some _assumption_ that all themes use MOST of them and so they are always registerr but some UIs are registered only by themes that use them ? You tell me what actually happens and I can help you word it.
The UIs are registered per L&F (and populated in `UIDefaults table` when user calls `UIManager.setLookAndFeel`) so we have `"ButtonUI", javax.swing.plaf.*** + uiClassID"` to find out the exact uiClassID, which implements that particular widget for that particular L&F, which in this case is `javax.swing.plaf.basic.BasicButtonUI`/`javax.swing.plaf.metal.MetalButtonUI` etc
However, Metal L&F has different themes and some uiClass are specific to particular themes so it seems they are further segregated and registered in specific theme's UIDefaults table (via `currentTheme.addCustomEntriesToTable(table)` in MetalLookAndFeel class) for ex, MetalMenuBarUI only for OceanTheme (and therefore are not registered upfront in L&F class)
which we are trying to establish here...
-------------
PR: https://git.openjdk.org/jdk/pull/11646
More information about the client-libs-dev
mailing list