primaryStage.show()
asks the system to show the window on the monitor screen.
In large programs
this is easy to forget.
If you run your program,
and nothing happens,
check that you have called this method.
When you create a Stage
object it is not automatically displayed.
A large application might create several Stage
objects, but might only
display one of them at a time.
In this picture, the pink clouds represent classes. Here is the program again:
import javafx.application.*; import javafx.stage.*; public class TestFX extends Application { public void start( Stage primaryStage ) { primaryStage.show(); } // Not needed for most systems public static void main( String[] args ) { launch(); } }
Explanation of the program:
Application
and Stage
.
Application
.
start()
method which overrides the abstract
method in the Application
class
Stage
and calls the start()
with a reference to it.
Stage
may be invoked.
primaryStage.show()
to put the window on the screen.
Must the parameter for start()
be named primaryStage
?