RFR: 8375578: Enable translucent window backdrops

Michael Strauß mstrauss at openjdk.org
Thu Jan 22 03:58:56 UTC 2026


On Thu, 22 Jan 2026 02:58:06 GMT, Christopher Schnick <duke at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/javafx/stage/Stage.java line 584:
>> 
>>> 582:      */
>>> 583:     @SuppressWarnings("deprecation")
>>> 584:     public final void initBackdrop(StageBackdrop backdrop) {
>> 
>> This API has the potential to age poorly, as enums are tricky to evolve. For example, what if a future backdrop type is configurable with a parameter? This could be improved by having the enum implement a sealed interface, so we can later add other backdrop types that can't neatly fit into an enum.
>> 
>> I also wonder how graceful degradation works with this API. It might be useful to be able to model a request like: give me a glass backdrop with a set of parameters, and if the platform doesn't support that, give me a `TRANSIENT` backdrop, and if the platform doesn't support that, I just want an opaque backdrop.
>
> Could perhaps the scene preferences be used for things like this? E.g. similar to having access to the platform styling keys, a user could manually override some of them to achieve the same result as with enums. That would solve any potential parameters and the degradation problem better

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
);

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2048#discussion_r2715208532


More information about the openjfx-dev mailing list