Free tutorials for Java, Eclipse and Web programming



JavaFX development with Eclipse - Tutorial

Lars Vogel

Version 0.5

19.10.2009

Revision History
Revision 0.114.12.2008Lars Vogel
First Version
Revision 0.210.01.2009Lars Vogel
Update article to reflect fixed bugs in the JavaFX plugin
Revision 0.302.06.2009Lars Vogel
Upgrade to JavaFX 1.2 and the new Eclipse Plugin
Revision 0.418.10.2009Lars Vogel
Minor re-work
Revision 0.519.10.2009Lars Vogel
Added timeline

JavaFX with Eclipse

This article describes how to develop your JavaFX application using Eclipse.

This article is based on JavaFX 1.2, Java 1.6 and Eclipse 3.5 (Galileo). This article assumes that you know how to use Eclipse for creating Java programs.


Table of Contents

1. JavaFX Script
1.1. Overview
1.2. JavaFX UI application
2. Installation
2.1. Installation of JavaFX
2.2. Installation of the JavaFX plugin
3. First JavaFX Script Project
3.1. Create Java Project
3.2. Code
3.3. Run
3.4. Adding Timeline, Events and binding
4. Slider Demo
5. Thank you
6. Questions and Discussion
7. Links and Literature

1.  JavaFX Script

1.1. Overview

JavaFX is a rich client platform for building cross-device applications and content. This article will use JavaFX script, the programming language for JavaFX. The following will use JavaFX as a short term for JavaFX script.

JavaFX script is a programming language from Sun for creating rich media and interactive content which is tightly integrated with Java. With JavaFX it should be easy to develop Rich Internet Applications (RIA).

It is a statically typed language which means that the data types of each variable, return value, etc. is known at compile time. JavaFX uses type inference / implicit typing to identify the type of a variable, e.g. the programmer does not have to specify the type himself. JavaFX is a declarative language, e.g. you describe what the application should do, rather then specifying the control flow of the application yourself. See Declarative programming for details.

The language provides data binding to connect UI elements with model elements.

JavaFX is compiled to Java byte code.

1.2. JavaFX UI application

The basis for a JavaFX UI application is the class javafx.stage.Stage. Within this stage you have a hierarchy of graphical elements which are described as part of a javafx.scene.Scene. These graphical elements are called nodes and can be:

  • JavaFX component, e.g. Image, Rectangle, Text, MediaView or a wrapped Swing component

  • JavaFX class (custom node)

  • Group: Container for other nodes