Java desktop links of the week, July 19

Well, no surprises this week with the news that the Oracle acquisition of Sun has been approved by shareholders. With the next step being Government consideration, we can only wonder how much longer Sun will be around. All I hope is that Oracle does it’s best to continue developing relevant Java technologies, and keeps Java pretty much on the path it is on now.

This week has been oddly quiet in the Java desktop world. Regardless, here are the most important Java desktop links of the week.

P.S. For anybody out there interested in hearing more Java desktop news, remember to follow me on twitter.





That’s us for another week. As always, feel free to email me any links you think are relevant. Have a great week!

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!

JavaFX: Building custom controls

One of the big criticisms leveled at JavaFX presently is its lack of controls (or components if you come from the Swing world). This was addressed to some degree in JavaFX 1.2, but there are still many controls missing, and some of the controls in the latest release have relatively basic API’s at this point. Certainly this will improve in future releases, but I thought I’d try to simply explain the process you need to go through to build your own controls. Who knows, you might be able to sell them if you get them good enough.

In JavaFX, there are three classes that you should become familiar with: Control, Skin and Behavior. Simply put, the Control class should be used to maintain state. It can have it’s look (but not feel) modified by assigning a different Skin instance to the skin variable. To separate the look of the control from how a user interacts with it, you should put all user interaction code into a Behavior instance, and assign it to the behavior variable within Skin.

I’ll jump right into a demo now. The demo is of a button (this term is used very, very loosely as I wanted to keep the code simple), and is split between three classes, as well as a test script to use the new button control. I have neglected to include any package and import statements, just to keep the code concise.

Firstly, the control itself simply has a text variable to store the buttons text. It also creates and sets an instance of the new skin, which handles the painting.

Secondly, we have the skin class shown below. It is necessary to implement the contains and intersects methods, but you can normally just reuse the code I have below for that. Note that I can access the control variable directly, but I cast it to be an instance of JGButton so I can access the text variable. Note also that I override the behavior variable to use my own implementation. Finally, you should note that I create a Group of nodes to represent my button, and I assign this to the node variable. I attach a few mouse listener functions to this node, allowing me to palm off the functionality to the behavior class. This allows me to change the skin without worrying about the behavior code needing to be needlessly duplicated to all skins.

Thirdly, we have the simple behavior class, which is where I have put in functions related to the buttons behavior. Oddly, the Behavior class offered by JavaFX only currently supports keyboard input, so it is necessary to write mouse input events from scratch. I’m not sure why this is, but perhaps Richard might leave a comment related to this. The only thing to note in this class is that I can access the skin and control through the skin and skin.control variables respectively.

Finally, we have a very simple test script, with nothing really worth noting. When the application starts, we have a red ‘button’ with the text “Button Text” printed atop it. When the mouse clicks on it, “Button pressed” is printed to the console. When the mouse moves over it, the text of the button changes to “Button entered”, and when it moves away from the button, the text changes to “Button exited”. Yes, it’s a very useful button.

I hope this quick and simple tutorial on creating custom controls in JavaFX has been useful. I tried to keep everything as simple as possible, but if you have any more detailed questions, please leave a comment or email me. Cheers!

JavaFX Node Bounds: I don’t get it

I’m happy to admit it when I don’t get something. The situation with boundsInLocal, layoutBounds, and boundsInParent in JavaFX is one of these situations. I have read a number of articles discussing this topic, and whilst I understand the differences between the three values technically, I don’t think I’ve seen an article that tells me why I need all three values, and when I should choose one over the other.

So, please, can someone out there write a blog post and/or add a comment to this post to explain to me, and to others, why I need to care about these three different values. If you do write a separate blog post, please leave a comment here so that anyone who stumbles upon this blog post in 6 months time can follow through to any other discussions elsewhere.

Most importantly, keep it simple. I know, that’s more difficult than being complex and detailed, but for the sake of JavaFX clarity the world over, please keep it simple. We want to know, simply, why and when do I care about the three different values?

Thanks in advance!