RFR: 8377426: Adjust scene background to color scheme
Andy Goryachev
angorya at openjdk.org
Wed Feb 11 09:55:33 UTC 2026
On Sun, 8 Feb 2026 03:30:51 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
> When a non-opaque scene fill color is used with a stage style other than `StageStyle.TRANSPARENT`, the actual fill color is always white. This doesn't work well when the scene uses a dark color scheme. A practical solution is to allow non-opaque scene fill colors, and blend them on top of a white or black background (depending on color scheme) to derive an opaque color that adapts intuitively to the color scheme.
>
> To test this, simply create a scene that uses a non-opaque fill color and observe the scene background when the color scheme is changed.
>
> This PR includes a system test, run it with:
>
> ./gradlew -PFULL_TEST=true -PUSE_ROBOT=true :systemTests:test --tests test.robot.javafx.scene.SceneFillTest.testSceneFill
hmm, something is wrong:
> Task :systemTests:test
SceneFillTest > testSceneFill(String, String, String) > [3] rgba(0, 0, 0, 0.75), rgb(63, 63, 63), BLACK FAILED
org.opentest4j.AssertionFailedError: expected: <0x3f3f3fff> but was: <0x404040ff>
at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at app//org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
at app//org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145)
at app//test.robot.javafx.scene.SceneFillTest.lambda$testSceneFill$1(SceneFillTest.java:96)
SceneFillTest > testSceneFill(String, String, String) > [4] rgba(127, 127, 127, 0.5), rgb(191, 191, 191), rgb(63, 63, 63) FAILED
org.opentest4j.AssertionFailedError: expected: <0x3f3f3fff> but was: <0x404040ff>
at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at app//org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
at app//org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145)
at app//test.robot.javafx.scene.SceneFillTest.lambda$testSceneFill$2(SceneFillTest.java:106)
SceneFillTest > testSceneFill(String, String, String) > [6] rgba(0, 100, 0, 0.8), rgb(50, 131, 50), rgb(0, 80, 0) FAILED
org.opentest4j.AssertionFailedError: expected: <0x328332ff> but was: <0x328333ff>
at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at app//org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
at app//org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145)
at app//test.robot.javafx.scene.SceneFillTest.lambda$testSceneFill$1(SceneFillTest.java:96)
6 tests completed, 3 failed
> Task :systemTests:test FAILED
[Incubating] Problems report is available at: file:///Users/angorya/Projects/jfx3/jfx/rt/build/reports/problems/problems-report.html
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':systemTests:test'.
> There were failing tests. See the report at: file:///Users/angorya/Projects/jfx3/jfx/rt/tests/system/build/reports/tests/test/index.html
* Try:
> Run with --scan to get full insights from a Build Scan (powered by Develocity).
Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/9.3.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 1m 14s
256 actionable tasks: 125 executed, 131 up-to-date
dhcp-10-89-197-66:rt angorya$ git status
On branch pull/2068
yes, macOS 26.2
the small difference is probably due to the color space, I think we had similar issues before.
also, on mac (edit: in light mode), I don't see the white background. what I do see is the background flickering momentarily to black before going to the set color, here is the test code (I might be doing something wrong though):
https://github.com/andy-goryachev-oracle/Test/blob/main/src/goryachev/bugs/Stage_Background_8377426.java
In the dark mode, I do see the screen flickering to white before going to the set color, using the same test with lighter color:
sc.setFill(Color.rgb(255, 255, 255, 0.2));
(the master branch simply goes full white w/o flicker in the dark mode)
-------------
PR Comment: https://git.openjdk.org/jfx/pull/2068#issuecomment-3880473703
PR Comment: https://git.openjdk.org/jfx/pull/2068#issuecomment-3880564753
PR Comment: https://git.openjdk.org/jfx/pull/2068#issuecomment-3880582488
More information about the openjfx-dev
mailing list