JavaFX


Posted by Steven

Last week, I gave a JavaFX workshop for my coworkers. It went very well and was a lot of fun! To share knowledge and make my work available to the community, I open sourced the whole workshop at github. There, you find

Posted by Steven

This week, I implemented a navigation pane in JavaFX that can be used to navigate within an application. It has four buttons with icons. At first, only the icon of each button is shown. At MouseOver, the pane expands and shows the button texts. One button can then be choosen and is highlighted with a drop shadow.

Here's the code as a SSCCE.

This is the controller ExtendableNavigation.java:

Posted by Steven

Yesterday, I implemented an extendable search pane in JavaFX. Having searched the web for a ready to use component, I found that most of the search panes hover above other nodes. But what if I want to extend the search pane by resizing other nodes, for example the results table? That is the only way to see all search results and all search options at the same time. This is what I build:

Posted by Steven

This week, I got around to adding some animation into the game and fixing a (again) thread-related bug.

Exiting the application

After playing around with the application, I noticed a problem: After a couple of executions from within eclipse, my computer got pretty slow. It turned out that after closing the application, one Java thread always stayed alive. The reason for this is my architecture. In my starting class, I called the JavaFX application as follows:

Posted by Steven

For the next iteration of my tiny game, I wanted to add some action. I decided to let resources grow on themselve: Every three seconds, a resource spawner should create one more resource. Because of the architecture of my application, I ran into some threading problems that shall be the topic for todays post.

As I wrote in a recent article of this series, the business logic of my application is separated from the Java FX user interface. This means that the reaction of a user input is determined by the classes in the business layer. Also, repeating events should be managed by the business layer and only graphically represented by JavaFX. Regarding the mentioned resource spawners, this means that the logic for the creation of new resources is stored in the business class ResourceSpawner:

Posted by Steven

This article is part of my JavaFX Series. Get the preceding articles here.

After setting up the basic world in which the simulation takes place, I decided to tweak the user interface a little bit. As you can see below, there are context menus at the resource spawners that allow for manipulation of the radius in which new resources are being spawned. The new objects now grow into existence by using a FadeTransition and a ScaleTransition.


Get the executable jar here.

Posted by Steven

With the last post of this series, I started experimenting with JavaFX. Since then, I figured out how to separate the user interface (UI) framework from the business logic and how the life cycle of the objects should be like.

First impressions

As I explained before, I want to write a small simulation in which some civilization uses growing resources to expand. The whole idea is pretty scetchy right now, but there should be a bord on which the whole simulation takes place and the mentioned resources. Because resources don't grow on their own, there are resource spawners that can be set programmatically and appear on the UI. These things spawn new resources every time the user clicks on them. The new resources (yellow thingies) are spread in a random fashion around the spawners (grey buttons):

Posted by Steven

I worked with Java Swing for quite some time now. However Swing is said to be dead since a couple of years, it seems that nobody notified some companies about that. I don't feel a siginificant movement away from Swing. But that doesn't mean that there will be none in the next years, so it's wise to be prepared for the next iteration of de-facto-user-interface-standard. After thinking and reading about some promissing candidates, I decided to bring myself up to date with JavaFX.