The JavaFX client template
Time’s up for the application client. The application client will use some JavaFX boilerplate code and a custom JNLP file we shall let NetBeans create for us. Therefore we shall create a temporary JavaFX project that we can steal stuff from. This project will not be added to our EAR project. We will only use this project as a nice template and later, we will delete the project.
In NetBeans, go to the menus and select File > New Project… > JavaFX > JavaFX FXML Application:
Please note a couple of things going on in this last screenshot. By default, NetBeans create some kind of a Default JavaFX Platform.. which I don’t use. As of Java SE 7 update 6, Oracle began distributing the JavaFX runtime libraries together with the Java SE downloads.
Also note that I create a MainFX application class. This will be the entry point for our JavaFX application. However, the ACC of GlassFish will invoke another Main class that kind of wraps our JavaFX application. Therefore I use different class names to separate the two classes from eachother. The ordinary Swing based Main class we shall soon create, will be named MainSwing. This class will hold the server side resources we need injected and I keep all JavaFX related stuff in a seperate class. You do whatever you like! I think you’ll get the picture soon enough.
As soon as you hit Finish, NetBeans will create some beautiful JavaFX code for you. However, we will also need that JNLP file I was talking about. Right-click your FXTemplate Project and select Properties. Select the Run tree node to your left. See the drop down list next to the label Configuration? Click on it and select Run as WebStart. Hit OK. Don’t worry about the screen dimensions, this shit can always be customized later.
Right click your FXTemplate project and select Clean and Build. This process will create the JNLP file for us. You cannot see the JNLP file in the projects tab, but you can see it in the Files tab > FXTemplate > dist.