Java Reference
In-Depth Information
primaryStage.setScene(scene);
primaryStage.show();
}
}
In step 1, you initiate a new project (shown in Figure 17-6 ) . In step 2, you select the
standard JavaFX application to be created. After selecting the project type, you specify
the name of the project. Make sure you click the Create Application Class check box to
allow the wizard to generate the MyJavaFXApp Java file. Once you have clicked Fin-
ish, your newly created application will appear in the Projects tab. Next, you change
the project's properties.
In step 5 you change two categories—Sources and Run. In the Sources category,
make sure the Source/Binary Format is set to JDK 1.8. After updating the Sources cat-
egory, you determine how the project will run (step 6) through the Run category. After
you select the In Browser radio button, notice the Width and Height options below the
working directory field. To use your own custom web page, click the Browse button to
select an existing HTML file. In this recipe, you can leave this area blank to allow the
wizard to generate a generic HTML page. Assuming that you are done with your set-
tings, you click OK to close the Project Properties window.
Lastly, you run your embedded JavaFX web application (step 7). To run your ap-
plication, make sure the project is set as the main project by selecting Run Set Main
Project MyJavaFXApp. Once you initiate a run, your browser will launch, contain-
ing a generic web page with your JavaFX application. You'll also notice that a conveni-
ent link allows you to launch the application as a Webstart application (not embedded).
Note Applets (Java applications that are embedded in the browser) are not the pre-
ferred way of deploying JavaFX applications, but they are covered in this recipe for
completeness. To learn about the different options for packaging and deploying JavaFX
applications, refer to the online guide at http://docs.oracle.com/javafx/2/
deployment/jfxpub-deployment.htm .
17-2. Loading Scalable Vector Graphics
File Content
Problem
Search WWH ::




Custom Search