JavaFX’s largest annoyance

JavaFX is great for building user interfaces. There is however one large annoyance that is probably considered a feature. JavaFX swallows NullPointerExceptions, among others.

NPE’s are meant to signal development errors. In other words, if you see an NPE, you can call your developer and tell him he screwed up. Some developers even need them to be reminded of the pieces of an application they were working on.

Continue reading

JavaFX : Centering Controls

Across the blogosphere, I found a post on how to center controls by using binding. The proposed method certainly works, but there is a catch.

When you are doing your layout by binding the layoutX and layoutY properties of your controls, you may experience a degradation of performance while resizing or scrolling. This will probably not be noticeable with only a handful of controls/shapes on screen. If however you start drawing hundreds of shapes/controls with this method, you will certainly see the slowdown. Let’s see why…

Continue reading

JavaFX Grid Component Worries

If you’re working with JavaFX, you will probably know these two truths:

  • The JFXtras library has some really awesome components
  • The JavaFX platform is trying out new controls in the preview packages

A good thing about this, is that the JavaFX team is taking the good stuff from the JFXtras library and putting it into the platform. A bad thing about it is you start to expect the preview controls have the same functionality as the JFXtras controls.

Continue reading

Moving Lines Around In JavaFX

Did you know, you can define ‘relative’ Lines in JavaFX? When you’re drawing complex visualizations, you sometimes want to have a Line that is horizontal and 10 pixels long, no matter what. No problem you say, just define its starting point as (x, y) and its end point as (x+10, y):

Line {
  startX: 40
  startY: 40
  endX: 50
  endY: 40
}

Sure, easy peasy. What if you want this Line to move around based on some variable’s value?Continue reading

JavaFX Transitions : An Oddity

I’ve been working on a nice looking application in JavaFX with some nifty transitions.  Doing so, I noticed an odd ‘requirement’ when working with Transitions. The problem arose when I tried to split my interface into different files. On one stage, I used two Stacks that each represented a state. Each Stack was defined in its own JavaFX script and another Script contained the transitions and event handlers.

What happened was that not all Transitions seemed to work. I have not yet been able to determine the root cause of it, but the Transition seemed unable to update properties of its target node. After some frustrated trial and error, I discovered a working solution: put the Transitions in the same file as their target node.

Again, I have not yet found the root cause. If someone can tell me why this is a problem, please let me know. I can’t stand not understanding 🙂

–JH

Integrating JavaFX with regular Java – Part 2

In my previous post about integrating JavaFX with regular Java, I briefly showed you how to properly construct a JavaFX object. This post will elaborate on that principle and provide the JavaFX UI a way to communicate with the Java ‘backend’.

Before I continue, I will explain the design of the application in which I used the method described below. This will allow you to decide whether this is also the way to go for your application, or maybe you still want to try something else. Ok, ready? Here we go!

Continue reading

Integrating a JavaFX UI with regular Java – Part 1

When JavaFX was first released, I didn’t give it much attention, as it felt like yet another visualization platform. With the latest release of JavaFX 1.3 and a project requiring a ‘fancy’ user interface, it was time to give it a try. The surprise came quickly: after downloading NetBeans and the JavaFX runtime, I was able to quickly build user interfaces that actually look cool.

After some tutorials and many bogus screens with crazy animations, it was time to put JavaFX to work on a real project. We had an application that receives a lot of data, processes this and stores it in a database. The data reception and processing were already fully developed in ‘regular’ Java using the Spring framework. The goal was to somehow try and integrate this existing code with a fancy JavaFX interface to visualize the data.

Continue reading