RFR: 8377426: Adjust scene background to color scheme [v2]

Michael Strauß mstrauss at openjdk.org
Thu Feb 12 20:19:02 UTC 2026


On Thu, 12 Feb 2026 18:59:38 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

> Thank you for clarifying. I accept the aesthetic reasoning, though still feel the amount of code you've added specifically for the ~200 ms of startup might be just a bit too much. Can it be useful in other places?

`PaintSampler` might be useful as it allows you to analyze gradients without actually rendering them, but I have no concrete plan to use it for another feature. In general, I'd like JavaFX support different color spaces in the future (color transitions tend to look much better in Oklab or linear sRGB), for which we'd probably reuse many of the color space transformations that currently live in `ImageUtils`.

> Would it be possible to alter https://github.com/andy-goryachev-oracle/Test/blob/main/src/goryachev/bugs/Stage_Background_8377426.java perhaps to allow for executing the different use cases? To help with the review process?

Here's a program with some examples:


public class SceneFillTest extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        var scene = new Scene(new VBox(), 800, 600);

        // Transparent black/white
        scene.setFill(Color.rgb(0, 0, 0, 0.5));
        //scene.setFill(Color.rgb(255, 255, 255, 0.5));

        // Stark linear gradient: transparent to black
        // scene.setFill(new LinearGradient(
        //     0, 0, 0, 1, true, CycleMethod.NO_CYCLE,
        //     new Stop(0, Color.TRANSPARENT), new Stop(1, Color.BLACK)));

        // Soft linear gradient with colors
        // scene.setFill(new LinearGradient(
        //     0, 0, 0, 1, true, CycleMethod.NO_CYCLE,
        //     new Stop(0, Color.RED), new Stop(1, Color.ORANGE)));

        // Image pattern
        // scene.setFill(new ImagePattern(new Image("path/to/bg1.png")));

        stage.setScene(scene);
        stage.show();
    }
}


And here are some background images, one with transparency and one without, which you can use to test the image pattern fill: [bg1.png](https://github.com/user-attachments/assets/748d2ed8-f9a1-42fd-a75f-8d4282c7bc22), [bg2.png](https://github.com/user-attachments/assets/412d3015-c55f-4052-8496-5dc1d4864d8f)

You should observe that with solid backgrounds, there should be no visible flash. Stark gradients have no really good single-color approximation, the algorithm will pick the average color of the gradient for the initial background. Soft gradients tend to work well, also notice that there is no jarring change from black/white to color.

With images, the initial color is the dominant color of the image, composited on the window background. Also make sure to toggle dark/light mode while the program is running to see the (partially) transparent scene fills adjust to the color scheme.

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

PR Comment: https://git.openjdk.org/jfx/pull/2068#issuecomment-3893172410


More information about the openjfx-dev mailing list