MenuButtonSkin fails to initialize in a background thread, throwing an IllegalStateException calling Toolkit.getToolkit().getSystemMenu().isSupported() in MenuBarSkin:822
```
@Test
public void menuBar() {
MenuBar c = new MenuBar();
c.setSkin(new MenuBarSkin(c));
}
```
## Root Cause
MenuBarSkin.rebuildUI() relies on Toolkit.getToolkit().getSystemMenu().isSupported() which can only be invoked in the FX application thread.
## Possible Solution
Postpone rebuildUI() until after the menu gets added to a Window (similarly to Chart fix https://bugs.openjdk.org/browse/JDK-8349091 ).
```
@Test
public void menuBar() {
MenuBar c = new MenuBar();
c.setSkin(new MenuBarSkin(c));
}
```
## Root Cause
MenuBarSkin.rebuildUI() relies on Toolkit.getToolkit().getSystemMenu().isSupported() which can only be invoked in the FX application thread.
## Possible Solution
Postpone rebuildUI() until after the menu gets added to a Window (similarly to Chart fix https://bugs.openjdk.org/browse/JDK-8349091 ).
- relates to
-
JDK-8349091 Charts: exception initializing in a background thread
-
- Resolved
-
-
JDK-8348987 ☂ Thread safety in Node initialization
-
- In Progress
-
- links to
-
Review(master) openjdk/jfx/1727