Most JavaFX objects, such as Node and Scene, can be constructed and modified on any thread unless and until that object is attached to a visible Window. Showing or hiding a Window is an operation that must always be done on the JavaFX application thread as documented in the Window and Stage classes.
The PopupWindow class defines additional show methods that are not documented to throw an exception, but in the cases where they do actually show the window, they will get an exception. Similarly the ContextMenu subclass of PopupWindow defines two more show methods with the same problem.
Some controls and skins also have operations that will show or hide a popup window. As with the above methods in PopupWindow, some operations can fail, often in hard-to-detect ways, if called on the wrong thread.
Here is the list of classes whose show and hide methods (and similar) should be documented to throw an exception if called on a thread other than the JavaFX Application Thread, and this restriction should be enforced at runtime:
Window subclasses:
javafx.stage.Window
javafx.stage.Stage
javafx.stage.PopupWindow
javafx.scene.control.ContextMenu
* Control subclasses
javafx.scene.control.ChoiceBox
javafx.scene.control.ComboBoxBase
javafx.scene.control.Dialog
javafx.scene.control.Menu
javafx.scene.control.MenuButton
* Skin subclasses
javafx.scene.control.skin.ComboBoxBaseSkin
javafx.scene.control.skin.ComboBoxPopupControl
javafx.scene.control.skin.ColorPickerSkin
javafx.scene.control.skin.DatePickerSkin
- csr for
-
JDK-8350962 Enforce threading restrictions for show and hide methods in Window, Control, and Skin
-
- Closed
-
- duplicates
-
JDK-8349004 DatePicker: NPE in show() when initialized in a background thread
-
- Closed
-
-
JDK-8349096 Split/MenuButton: exception initializing in a background thread
-
- Closed
-
- relates to
-
JDK-8348987 ☂ Thread safety in Node initialization
-
- In Progress
-
-
JDK-8348423 [TestBug] stress test Nodes initialization from a background thread
-
- Resolved
-
-
JDK-8349750 [TestBug] NodeInitializationStressTest: remaining Nodes
-
- Resolved
-
-
JDK-8349004 DatePicker: NPE in show() when initialized in a background thread
-
- Closed
-
-
JDK-8349096 Split/MenuButton: exception initializing in a background thread
-
- Closed
-
- links to
-
Commit(master) openjdk/jfx/b5f76ad4
-
Review(master) openjdk/jfx/1717