On Thu, 22 Jan 2026 11:38:48 GMT, John Hendrikx <[email protected]> wrote:
>> I'm not sure about scene preferences, as the supported backdrop materials
>> are not exactly a _preference_. It's not something users can change about
>> the system.
>>
>> How about something like this:
>>
>> public sealed interface StageBackdrop {
>>
>> enum Generic implements StageBackdrop {
>> DEFAULT,
>> WINDOW,
>> TABBED,
>> TRANSIENT
>> }
>>
>> record Specialized(String name, Map<String, Object> parameters)
>> implements StageBackdrop {
>> public Specialized(String name) {
>> this(name, Map.of());
>> }
>> }
>> }
>>
>>
>>
>> public class Stage {
>>
>> public final void initBackdrop(StageBackdrop... backdrop) {
>> ...
>> }
>> }
>>
>>
>> The `initBackdrop` method would take a list of options in order of
>> preference. Maybe I could then configure my backdrop like so:
>>
>> myStage.initBackdrop(
>> // first choice
>> new StageBackdrop.Specialized(
>> "NSGlassEffect",
>> Map.of("style", "NSGlassEffectViewStyleClear")
>> ),
>>
>> // second choice
>> StageBackdrop.Generic.TRANSIENT
>> );
>
> Should we have a (new kind of) fallback system, or should we do this with the
> existing `Platform.isSupported(ConditionalFeature)` and have the user decide
> based on the result of that function?
I agree that an enum is inadequate. The two API's we have to work with (macOS
and Win11) are based on enums; you specify the type of window or content (e.g.
tooltip, menu, sidebar, window) and let the OS decide what material to use.
macOS pro-actively enumerates a lot of different window types though it looks
like many of them map to the same material under the hood. I'm not entirely
sure the glass effect recently added to macOS is appropriate for JavaFX but it
is a prime example of a specialized platform-specific backdrop that can't
easily be squeezed into an enum.
So, yes, we should expand StageBackdrop so we can provide more information. How
to do that might be beyond my pay grade (I'm not a Java expert). I don't think
the existing `Platform.isSupported()` API would be appropriate since it takes a
separate enum type.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2048#discussion_r2718168893