JavaFX - Articles, Tutorials and Examples

11.08.2013

JavaFX - Alien Rallye.
This article describes how to parse the content of a SVG path element and create a set of JavaFX PathElements which are added to a javafx.scene.shape.Path. The idea behind this is that the JavaFX Path can be used to create a PathTransition. I used the Apache Batik parser to split the SVG path element and wrote my own PathHandler to create the PathElements. This means: Parse a SVG string M 150 50 L 550,50 A 50 50 0 0 1 600,100 L 600,350 and create PathElements (ArcTo, LineTo, MoveTo, CubicCurveTo).

Weiter

27.07.2013

JavaFX - Lottery Wheel.
This article shows how to use TranslateTransitions, FadeTransitions, Timelines and Timeline chaining to implement a simple lottery wheel where names rotate around a point. The wheel reduces its speed continuously and at the end the winner name is highlighted. The names are loaded from a simple text file and positioned around the middle point. The winner is indicated by an arrow which is created with a Path. The Font size and the Color of the names depends on the angle where they are placed around the circle...

Weiter

29.06.2013

JavaFX Puzzle Game.
The following article describes how to create a simple Puzzle game with JavaFX. In this example MouseEvents are used to trigger the move of a puzzle tile from one position to the next. The EventHandler is registered on a Rectangle with setOnMouseClicked. The colors of the tiles can be customized via a CSS file. Also a Property Binding is used to update the text value of a Label automatically...


Weiter

28.04.2013

How to use and extend the library JFXtras.
This article describes how to compile the latest version of the JFXtras library in your own IDE so it is possible to debug directly into the source code and make changes which can be contributed to the project. I describe several ways to import and build the JFXtras library with Netbeans, Eclipse, Gradle, the e(fx)clipse plugin and the Eclipse Gradle Integration. Also I explain how to use Git to fork and clone the repository so you can contribute new components or bug fixes to the project...

Weiter

29.03.2013

JavaFX - Fractal: The Mandelbrot and the Julia Set.
The following article describes how to paint the Mandelbrot and the Julia set with JavaFX. Also I explain how to change the colors of the graphical representations of the sets. Additional the look of the Julia set can be changed by adapting the function values...


Weiter

22.03.2013

How to get a list of all JavaFX color names which are pre-defined in the class Color?.
The class javafx.scene.paint.Color in JavaFX has a lot of pre-defined static color names. The usage is very simple, e.g. Color.BLUE. But how do you get a list of all these color names which are defined in the class Color? This article describes a way which uses the Java Reflection API to create a list with all these color names...


Weiter

21.03.2013

JavaFX - Mandelbrot Set.
The following short article describes how to paint a Mandelbrot set with JavaFX. The Mandelbrot set will be painted into a javafx.scene.canvas.Canvas with the methods GraphicsContext.setFill() and GraphicsContext.fillRect()...



Weiter

17.03.2013

JavaFX - Dartboard with Shapes (Path, Arc, ArcTo, Circle) and Text.
The following article describes how to paint a dartboard with JavaFX. This article tries to describe how to use primitive shapes to paint a complex Scene with JavaFX. A side-effect is that you will learn how to use trigonometric functions like sine and cosine and place points at an arbitrary position on a circle. In the example, a Scene is created which contains some javafx.scene.shape.Circle objects, javafx.scene.shape.Arc...

Weiter

14.03.2013

JavaFX - Animation of Circles with a Timeline.
The following article describes how to animate objects in JavaFX. In the example, a Scene is created which contains some objects (javafx.scene.shape.Circle-Objects) which are flying around an imaginary middlepoint. The animation is realized with a JavaFX javafx.animation.Timeline and javafx.animation.TranslateTransitions to move the objects from one point to the next position around the orbit. The objects are styled by a CSS file which defines a...

Weiter

06.03.2013

Game of Life mit JavaFX.
In dem folgenden Beispiel wird mit JavaFX eine einfache Oberfläche für Game of Life erstellt. Die Zellen werden mit javafx.scene.layout.StackPanes realisiert, die innerhalb eines javafx.scene.layout.Pane angeordnet sind. Die StackPane-Objekte werden mittels eines javafx.scene.layout.StackPaneBuilder erstellt. Die Anmination wurde mit einer javafx.animation.Timeline umgesetzt...

Weiter

05.03.2013

Ein Schachbrett mit javafx.scene.shape.Rectangle und CSS-Styling.
In dem folgenden kleinen JavaFX-Beispiel wird ein Schachbrett mit den Klassen Rectangle und dem RectangleBuilder erstellt. Das Aussehen der schwarzen Felder wird über eine CSS-Datei gesteuert. Zu Einsatz kommen außerdem noch die JavaFX-Klassen Application, Pane, Scene und Stage...


Weiter