Java Reference
In-Depth Information
Steps 2 through 4 are illustrated in Figure
13-12
.
Figure 13-12.
Adding the ScalaFX jar file to your project
Now you are ready to create your first ScalaFX application. To start, we create a very simple ScalaFX application
that shows a
Stage
and
Scene
with a single
Label
inside it. This is the Hello World of JavaFX applications, and will
ensure that all your project settings are correct and you are ready to build larger applications.
To create a new ScalaFX class, choose New
➤
Scala Object from the File menu. This opens a wizard in which
you can set the name of your class to
HelloScalaFX
and select the
scalafx.application.JFXApp
class from which it
should extend. On completing the wizard, Eclipse will create a stub class for you.
To complete the example, you need to add a
Stage
,
Scene
, and
Label
to your application. The full code for the
Hello ScalaFX application is shown in Listing 13-10.
Listing 13-10.
Hello ScalaFX Application to Test Your Newly Created Project
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene
import scalafx.scene.control.Label
Search WWH ::
Custom Search