Java Reference
In-Depth Information
stage . setScene ( new
new Scene ( rootPane , 300 , 200 ));
stage . show ();
}
public
public static
void main ( String [] args ) {
launch ( args );
static void
}
}
Note that no Swing imports are used; Button is from JavaFX, not from Swing.
Th e main program has to extend the JavaFX Application class.
Li ke an applet, no constructor is provided; instead, the override of start() is called,
passing in a Stage (which is analogous to a JFrame).
Di fferent action handling method, but exactly the same concepts as in Action Handling:
Making Buttons Work .
A Pane ( StackPane ), analogous to a JPanel , is created, and the button added into it; the
Pane is then wrapped in a Scene , which is added to the Stage . Now the whole thing is
ready to show.
Th e main program doesn't need to instantiate anything, but just calls the inherited
launch() method, passing in the command-line arguments.
Figure 14-16 shows this program on display.
To learn about using the drag-and-drop GUI builder for JavaFX, consult the Oracle art-
icle, “Installing JavaFX Scene Builder” . There is tutorial information on full develop-
ment of applications using JavaFX . Although the IDE notes there are mainly or only for
NetBeans, you can adapt them (I ran Figure 14-16 under Eclipse).
 
 
Search WWH ::




Custom Search