Java desktop links of the week, July 13

Here is another weeks fresh Java desktop links, served steaming hot straight to you – just the way I know you like it.





  • Andres Almiray keeps his blog on all things Groovy churning out the hits, this week with two on GfxBuilder. The first post is about custom nodes, and the second on transforms and plugins.

That’s it for another week. Keep up the good work everyone, but for those of you up in the northern hemisphere, get outside and enjoy the sunshine 🙂

Java desktop links of the week, July 6

Well, I’m glad I got around to learning JavaFX as the quantity of news is hugely sliding towards JavaFX these days. This week is no different. Despite this, if you have any Java desktop related news, please feel free to email me. Lots of people do, and it makes my life a little easier 🙂 You can find my email to the right on every page. Here we go again – enjoy.



  • Ken Orr lets everyone know that a co-worker of his, Jared MacDonald, spoke at JavaOne on building bullet proof user interfaces using test-driven development. The slides (in pdf form) are available for download.
  • Mariusz Trzaska emailed me to let me know of a project he has been working on called gcl-dsl, which stands for ‘GUI Creating Language Domain Specific Language’. As suggested, it is designed to make it easier to build user interfaces in Swing.
  • Alexander Potochkin (from the Swing Team at Sun) emailed me to let me know of CollectionSpy, which is a commercial application designed to profile Java applications which make use of collections. It is also written in Swing. An observation I’d like to make is that developers who write profiling software are very good at making good looking applications. Look at software such as JProfiler and YourKit.



That’s another week down. Have a great week everyone!

Java desktop links of the week, June 29

To everyone reading and commenting on my blog – thanks – you help make the world go round 🙂 Here we go again.





  • Andres Almiray posted two updates on FxBuilder for Groovy.

Have a great week everyone, and for those of you in the northern hemisphere, enjoy the nice weather – it’s freezing and dark here in New Zealand!

JavaFX: Bound functions

Binding in JavaFX is of course very cool, and in most circumstances it makes sense. I thought I would make a quick post to explain what a bound function is, and how you should go about interpreting code that uses this language feature. I want to make this post as simple as possible, so as to not overcomplicate things. Before I begin I must thank the Pro JavaFX Platform book guys – I base this explanation on code from their (highly recommended) book.

A bound function looks like this:

The interesting thing about this function declaration is the bound keyword. Looking at the body of the function, we note that the function makes use of variables y and z from the function, and assigns these to variables u and v respectively. In actual fact, the z argument is never used, but an x value is used. This x value is declared outside the function, and is therefore available to be used by it.

This function can be used as per usual in our code simply by calling f(1,2), for example. The feature that is offered by the bound modifier is that we can bind to the function, and when the x or y variables values change, the function will re-evaluate itself. An example is shown in the code below:

On line 3, c is bound to equal the result of calling the function f(a, b), which will result in c being set to equal 7.0 (as a=4,b=5, and x=3, and f is the sum of a and x).

Line four changes the value of x from 3 to 5. Because the f function is a bound function, and the c variable is bound to the f function, we re-evaluate f(a, b), and assign the new value of a+x to c, which means that c is now equal to 9.0.

Similarly, when the a variable is changed on line 5, the function is re-evaluated, as it has determined that the value of a is relevant to the value stored in c.

As noted previously, the value of b is not used in the function, and therefore when it changes it does not impact on the value of the variable stored in c. Because of this, when the value of b is changed on line 6, c is not re-evaluated, as JavaFX is smart enough to know that this does not matter.

If the c variable was declared as f(a, b) (i.e. it is not bind f(a, b)), then when x is updated, c will not be recalculated. Similarly, if the function declaration for f is not declared to be bound, c will not be updated either. However, both of these permutations are legal syntax – it just results in different outcomes. To have f re-evaluate itself and the value be assigned to c, it is necessary the both the function be declared bound, and the assignment to variable c be bound (using the bind keyword).

I hope that makes sense, and clarifies the purpose of the bound keyword.

JavaFX: Thick TextBox Borders

Being the UI geek that I am, I wanted to look at borders in JavaFX, as I had noticed that there seemed to be some inconsistencies. It turns out that I shouldn’t have been too worried – it appears that only one control looks bad, and it is the TextBox control. Shown below is a screenshot of a demo application I wrote, which has a number of controls placed in it.


Note that the borders of all controls look pretty similar – a single pixel width and all a dark grey. Swing suffered from border abuse and inconsistent border colours, so I am happy to see JavaFX is much better.

As mentioned, the only exception is the TextBox, which in the screenshot says ‘Original’. I think it’s probably agreeable to most people that this control has a border which is too thick (and a font which is not consistent with the font used in other controls). To fix the border inconsistency is actually quite simple, as shown in the TextBox directly beneath the original which shows ‘Fixed’. I think it’s probably agreeable that this fits it better with the other controls.

Finally, beneath the ‘Fixed’ TextBox is the text ‘Invisible’, which is actually also a TextBox with no border being shown. I include this for a reason, which will become clear soon.

Anyway, on to the fix – it’s simply a matter of changing the style by adding a line of CSS. The code for the three text boxes is shown below, in the same order as shown in the screenshot.

In otherwords, to fix the border problem, you need to set the border-width to 0, which doesn’t seem correct – you’d expect a control with a border-width of 0 to have an invisible border. In fact, to get an invisible border is shown in the last TextBox – you have to set border-width to be -1.

So, perhaps this is a bug, or perhaps it’s a design choice. I thought I would document it here so that people searching Google for answers might discover it without having to do trial and error. Perhaps this might be fixed in a future JavaFX release.

Additionally, the TextBox font also seems to be inconsistent, but I won’t bother to discuss this as I would hope anyone reviewing this post will also realise they need to fix the font. Perhaps this may be fixed in a future JavaFX release too.