Java desktop links of the week, June 22

Another busy week, especially in JavaFX land. I hope everyone is settled back in to work after the JavaOne distraction, and that conference-driven development can be forgotten for another 9 months. On with the news.

General

  • Congratulations goes to Alex Ruiz, author of the FEST testing software, on the news that he and his wife had a baby girl this week. This is Java desktop related news only as it has already been decided that Colette will be a Java desktop developer in 20 years time.
  • Josh Marinacci posted a FAQ for the Java Store.
  • Often times when you present time to users, it doesn’t need to be precise. This is becoming more popular, especially on the web. If you want to have similar output for your users, look in to PrettyTime, which is an LGPL3 library designed to display human-readable timestamps like, “right now”, “2 days ago”, or “3 months from now”.

Swing

JavaFX

Groovy/Griffon

  • Andres Almiray posts about the latest FxBuilder, which has support for JavaFX 1.2, including the new controls, charts, etc.
  • Why do we need JavaFX when we have Groovy?’ is the question asked by teamlalala.com. They then go on to provide a good discussion around the code to draw a coffee cup in both JavaFX and Groovy. Personally, I don’t think the question is fair – why can’t we have JavaFX and Groovy – it’s not like Sun would ever drop JavaFX to instead support Groovy, and I would suggest that for the time being at least, there are far deeper pockets behind JavaFX than many other languages out there.

That’s it for another week. Keep working hard, and, as a (relatively) local comedian would say: say hi to your mum for me.

Mini ‘Pro JavaFX Platform’ Book Review

JavaFX is a very, very fast moving platform (language and API in particular). Fair enough too – it’s come a remarkably long way since it’s inception, and that can’t be a bad thing (except for the whole ignoring Swing thing). As I was busily using Java and Swing, I applied the ostrich principle and buried my head in the ground. I even kicked up a fuss that there should be a proper Swing 2.0. I still stand by that sentiment, but am pleased with the progress of the Swing Generics project, which has very similar goals to my initial discussion (although it clearly doesn’t go as far as one faction of Swing 2.0 supporters, but that’s another story entirely). Because of this I feel I can at last investigate JavaFX without feeling like I’m abandoning the Swing 2.0 cause.

Unrelatedly, I was fortunate enough to have Sun sponsor me to go to JavaOne in San Francisco this year. The highlight for me was meeting everyone I knew virtually, but had never met in real life before. Three of the people I met at JavaOne were three of the four authors behind ‘Pro JavaFX Platform: Script, Desktop and Mobile RIA with Java Technology‘, namely Stephen Chin, Jim Weaver and Weiqi Gao (the other author I missed is of course Dean Iverson).

As I alluded to in the first sentence, JavaFX is a very fast moving target, and so a book is going to struggle to be useful for very long. With the release of JavaFX 1.2, I would assume that most books are somewhat out of date (based on feedback I’ve heard from other people and Amazon reviews). I was not about to learn an older version of JavaFX, so I was pleased to hear that the Pro JavaFX Platform book was completely updated to be JavaFX 1.2 compatible. It would be nice to know which of the other JavaFX books are current, so if anyone knows, please leave a comment (particularly the ‘JavaFX: Building Rich Internet Applications‘ and ‘Essential JavaFX‘ books, which are also both new releases as of JavaOne).

Apress, the publishers of the book, put out an alpha release of the book. The final release I believe is due around mid July. The authors were generous enough to give me a copy of the alpha ebook to read for my own purposes (i.e. they didn’t ask for a review). I thought I’d be kind and give them chapter feedback, so I hope I’ve helped to improve the book quality a little.

So, the book. It’s very good if you are a Java developer who knows nothing of JavaFX. Even if you don’t know Java, it should still be readable, as chapter two provides a very comprehensive background and introduction to the language. It probably isn’t a book for a person new to programming – they should probably get an intro to programming book first – but then what do you expect from a book starting with the word ‘Pro’? 🙂

Jim (one of the authors) wrote up a good summary of what is in each of the chapters on his blog, so I won’t bother to repeat it here.

What I did want to do however was add my personal opinion of the book. Before reading the book I could ‘hack’ at JavaFX, and of course it was always pretty trivial to read JavaFX code and understand it. Since reading the book I have a better understanding of how to build a JavaFX application properly. I also have a far better understanding of the quirks of JavaFX. As I’ve mentioned elsewhere, JavaFX needs better support for Containers (i.e. layout managers in the Swing world), and whilst JavaFX 1.2 goes some way to helping in this area, the book gives a good introduction to new containers offered in JFXtras, such as the JavaFX port of MigLayout. Finally, it gives a good tutorial as to how you should go about developing a mobile offering of your application.

Some of the chapters are very advanced, so I know that I will be returning to the book when I hit areas of difficulty in JavaFX. In this regard, it doesn’t feel like it’s the kind of book that you read once and then shelve on your bookshelf. It will be a good reference manual for anybody building JavaFX applications.

If you are a Java developer who tends to spend time developing user interfaces in Swing, and want to get to know JavaFX, then I happily and wholeheartedly recommend the Pro JavaFX Platform book to anybody out there. I can assure you that it is a good book, and it will get you up to speed very quickly. It is current as of it’s release (due to the hard work of the authors who pretty much wrote the book 1.5 times), so you need not worry that you’re learning old language and API’s. Apparently, future releases of JavaFX are less likely to be ‘breaking’, in the sense of API and language changes, so now is probably a good time to invest in a good resource to learn JavaFX.

If you’re interested in the book, buy the ebook or the printed version when it comes out.

Finally, this has not been a paid advertisement for Pro JavaFX Platform: Script, Desktop and Mobile RIA with Java Technology, although I wish it was 🙂

JavaFX Magic 8 Ball

I was working on a Magic 8 ball written in JavaFX just to try a few things out, and people asked for the code, so here it is. It is nothing special, although I did try to comment the relevant code to make it a bit easier to understand. At around 150 lines of code (including whitespace and comments), it is a very small program, and a good example of what is possible with JavaFX.

To shake the magic 8 ball, you do that – you click on it and shake the ball around. Once you let go the message is updated.

Part of the reason I’ve posted this is so that people can tell me how to improve my code. If I’ve done some stupid (likely derived from my life as a Java developer), please let me know.

You can (hopefully) run the Java Web Start version of it here:

A screenshot of the program is shown here:
magic8

When the ball is shaken, the text and the triangle fade out, and then the triangle fades in with a new message.

A source code download (along with the background image), is available from here. I know I could have coded the ball in JavaFX, but frankly using an image is far easier 🙂

Finally, here is the code. Apologies for the need for horizontal scrolling, but it is the best I can do without changing the theme of this site to be wider.

Java desktop links of the week, May 10

Hey everyone. This post is going out a bit early as I’m actually away at my wifes graduation from vet school. I apologise that I am not as up to date as could be – I promise to have a better post next week! Regardless, I hope you enjoy!

Swing

  • Alexander Potochkin posted a short blog post updating people on the state of Swing tech in JDK 7 . In short, Nimbus (as we know) has been merged, and JXLayer is likely to be merged shortly. I have made extensive use of JXLayer in my projects, and highly recommend it. Some examples of JXLayer code can be found here .
  • Talking about Java 7, Kirill Grouchnikov released a video showing an animated JFrame which makes use of the Window.setOpacity() API which is new to Java 7.
  • Alex Ruiz posted announcing the release of FEST-Swing 1.2a1 .FEST-Swing is a Java library that provides a fluent interface for functional Swing GUI testing. This library provides an easy-to-use API that makes creation and maintenance of GUI tests easy. Version 1.2a1 is the first out of three alpha and three beta releases planned for version 1.2. This new version focuses on new features and improvements.
  • Christophe emailed me to let me know of BeanTableModel , which is a dedicated  binding solution (bi-directionnal) between POJO and a TableModel, where all configuration is done by java annotations.
  • I was looking for a Swing-based system tray library this week, as the API made available in Java 6 is AWT-based, and looks ugly. After much searching, the best code I could find was from the fishFarm project, and is an extension of other similar projects to try and remove various operating system quirks. You can find the single class, called JPopupTrayIcon, here .
  • Maxim Zakharenkov emailed me to let me know that Swing Explorer 1.4 has been released. As always, It can be found on the downloads page.

J avaFX

That’s it for the week. Keep up the hard work 🙂

Java Desktop links of the week, March 9th

This week there is a rather large amount of JavaFX news, but very little Swing news. I guess this is a sign of the times 🙂

Swing

  • Coming into my feed reader after posting this blog, I thought I’d quickly add that Ken Orr has a blog post about creating a custom HUD-style combo box.
  • Alexander Potochkin has blogged that the Swing Application Framework is back again. For more background, check out this interview with Hans Muller, back when the project was first approved. SAF has had a turbulent life, most recently with Karsten Lentzsch disapproving of its current state, and whether or not it actually will make it into Java 7 is yet to be seen.
  • InformIT has a post discussing playing media in Java using JMC. All code samples are written in Java, not JavaFX Script.
  • Regarding Swing 2.0, in the 13/02/09 podcast of This Ain’t Your Dad’s Java!, Sun’s Java marketing team has briefly discussed the recent discussion around Swing 2.0. You can listen to the podcast here if you have iTunes (skip forward to around the 5:00 mark. It continues until around the 9:15 minute mark). Their general perspective was that people wanting Swing 2.0 are trolling, whiney and fanboys. Also, despite their protests that Swing is strong, they inferred a number of  times that Swing  is on its way out. I found their means of communication to be somewhat condescending and rude, but perhaps that’s just me. For marketing people who are putting out the opinion of Sun, I found this to be disappointing.

JavaFX

Eclipse/SWT