Session 7 |
Introduction
JavaFX is a framework for developing Java GUI (graphical user interface) programs. This session material serves two purposes. First, it presents the basics of JavaFX programming. Second, it uses JavaFX to demonstrate object-oriented programming and design.
Historically, there have been many possibilities for creating graphical user interfaces in Java. When Java was introduced, the GUI classes were bundled into a library known as the Abstract Windows Toolkit (
AWT
). AWT is can be used for developing simple graphical user interfaces, but not for developing comprehensive GUI projects. The AWT user-interface components have been replaced with a more robust, versatile, and flexible library known as Swing components. Swing
is now replaced by a completely new GUI platform known as JavaFX
. It has a large functionality which cannot be covered within one practice session. In this session, we will study a few examples in order to get a taste of JavaFX and guidelines how to use this library on your own.
Before we will proceed with the first JavaFX program, make a few preliminary steps. First check if the JavaFX plugin is enabled in IntelliJ (File -> Settings -> Plugins). Then create a project as usually (New -> Project), but on the first page of the wizard, in the left-hand pane, select JavaFX:
In the JavaFX project there are some classes already (Main
and Controller
) in the package sample
. Try to run Main
program and we will get the first (empty) graphical window.
Session 7 |