77import java .util .concurrent .CountDownLatch ;
88import java .util .concurrent .TimeUnit ;
99import java .util .concurrent .atomic .AtomicReference ;
10- import javafx .animation .Animation ;
11- import javafx .application .Platform ;
12- import javafx .scene .input .MouseButton ;
13- import javafx .scene .input .MouseEvent ;
10+
1411import org .junit .jupiter .api .AssertionFailureBuilder ;
1512import org .junit .jupiter .api .BeforeAll ;
1613import org .junit .jupiter .api .Test ;
1714import org .junit .jupiter .api .Timeout ;
15+ import org .junit .jupiter .api .condition .OS ;
16+
17+ import javafx .animation .Animation ;
18+ import javafx .application .Platform ;
19+ import javafx .scene .input .MouseButton ;
20+ import javafx .scene .input .MouseEvent ;
1821
1922class KeyButtonTest {
2023
2124 @ BeforeAll
2225 static void initToolkit () throws Exception {
23- // Ensure headless property is set early in CI via JAVA_TOOL_OPTIONS; this is
24- // just in case.
25- System .setProperty ("java.awt.headless" , System .getProperty ("java.awt.headless" , "true" ));
26- System .setProperty ("prism.order" , "sw" );
27- System .setProperty ("prism.forceGPU" , "false" );
28- System .setProperty ("glass.platform" , "Monocle" );
29- System .setProperty ("monocle.platform" , "Headless" );
30-
26+ if (!OS .WINDOWS .isCurrentOs ()) {
27+ // Ensure headless property is set early in CI via JAVA_TOOL_OPTIONS; this is
28+ // just in case.
29+ System .setProperty ("java.awt.headless" , System .getProperty ("java.awt.headless" , "true" ));
30+ System .setProperty ("prism.order" , "sw" );
31+ System .setProperty ("prism.forceGPU" , "false" );
32+ System .setProperty ("glass.platform" , "Monocle" );
33+ System .setProperty ("monocle.platform" , "Headless" );
34+ }
3135 // Initialize JavaFX toolkit (safe if already started)
3236 try {
3337 Platform .startup (
@@ -36,7 +40,7 @@ static void initToolkit() throws Exception {
3640 });
3741 } catch (IllegalStateException ex ) {
3842 // toolkit already started
39- } catch (NullPointerException | RuntimeException ex ) {
43+ } catch (RuntimeException ex ) {
4044 // Handle glass platform initialization failures in JDK 25+
4145 // This can occur when the glass platform factory is not properly initialized
4246 System .err .println ("Warning: Failed to initialize JavaFX toolkit: " + ex .getMessage ());
0 commit comments