The
Application Thread
In the preceding discussion,
it was mentioned that you cannot use the init(
) method to construct a stage or scene. You also cannot create these items
inside the application’s constructor. The reason is that a stage or scene must
be constructed on the application thread. However, the application’s
constructor and the init( ) method are called on the main
thread, also called the launcher thread.
Thus, they can’t be used to construct a stage or scene. Instead, you must use
the start( ) method, as the skeleton
demonstrates, to create the initial GUI because start( ) is called on the application thread.
Furthermore, any changes to
the GUI currently displayed must be made from the application thread.
Fortunately, in JavaFX, events are sent to your program on the application
thread. Therefore, event handlers can be used to interact with the GUI. The stop( ) method is also called on the
application thread.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.