Institute of Computer Science
  1. Courses
  2. 2019/20 spring
  3. Object-Oriented Programming (Narva College) (LTAT.NR.003)
ET
Log in

Object-Oriented Programming (Narva College) 2019/20 spring

  • Home
  • Materials
  • Grading
  • Java Glossary
  • Cheat sheet (S1-S6)
  • Source Example
  • Links
Chapter 7

Introduction

JavaFX is a framework for developing Java GUI (graphical user interface) programs. The material of this chapter 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 Window Toolkit (AWT). AWT can be used for developing simple GUIs, 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 chapter. In this chapter, 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:

  • save and unzip the initial project: project.zip
  • check IntelliJ updates (Help->Check for updates) and plug in Gradle (File->Settings->Plugins)
  • open a new project (File->Open) and browse for the folder which contains build.gradle (not subfolder src)
  • in the new window, choose the following options:
  • once the installation is completed, open build.gradle and make sure that mainClassName = is assigned the name of the main class:
  • next open gradle menu (View->Tool Windows->Gradle) and run the program (double click on run launches the main class set in build.gradle):

If you use Java 10 or earlier version

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.

Chapter 7
  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment