Monday, January 26, 2015

JavaFx: Hello World

In this tutorial we will print the customary "Hello World" to console and the the GUI using JavaFX.



  • First we have to create a new Module (new application)
  • select Maven app






Type in group ID "edu.clc.cit137"
Type in artifact ID "javafx-hello"







Create a NEW Java Class (or File) named "HelloWorld.java"





Analyze the simple GUI in the image below.

Please type all Java code, click on the image to enlarge full screen.



In the second part of the code we have an EVENT handler for the BUTTON.
And layout of the widgets using HBox and VBox.



Finally, notice that package says "helloworld", however we are not in that package. Control click (command 1) on RED underline until options show up, select "Move to package..."



Run the app