FX Experience Has Gone Read-Only

I've been maintaining FX Experience for a really long time now, and I love hearing from people who enjoy my weekly links roundup. One thing I've noticed recently is that maintaining two sites (FX Experience and JonathanGiles.net) takes more time than ideal, and splits the audience up. Therefore, FX Experience will become read-only for new blog posts, but weekly posts will continue to be published on JonathanGiles.net. If you follow @FXExperience on Twitter, I suggest you also follow @JonathanGiles. This is not the end - just a consolidation of my online presence to make my life a little easier!

tl;dr: Follow me on Twitter and check for the latest news on JonathanGiles.net.

Correctly Checking KeyEvents

I was just writing a quick little application and I wanted to do something special whenever the user released the enter key inside a TextArea. You might be tempted to do it like this:

final TextArea editor = new TextArea();
editor.setOnKeyReleased(new EventHandler<KeyEvent>() {
    public void handle(KeyEvent t) {
        if (t.getCode() == KeyCode.ENTER) {
            System.out.println(editor.getText());
        }
    }
});

Can anybody spot the problem in this code? It correctly gets the key event, and it only prints out the text if the code of the key event is ENTER. The problem is that it also executes this code if you typed ALT+ENTER, or CTRL+ENTER, or any other combination of modifiers with the key code! JavaFX 2.0 contains a handy little class called KeyCombination which will handle all the annoying checking of key modifiers + key code to see if a specific key event matches. Here is the more correct version:

final TextArea editor = new TextArea();
editor.setOnKeyReleased(new EventHandler<KeyEvent>() {
    final KeyCombination combo = new KeyCodeCombination(KeyCode.ENTER);
    public void handle(KeyEvent t) {
        if (combo.match(t)) {
            System.out.println(editor.getText());
        }
    }
});

One extra line of code, and you get correct matching of the key events. Sweet!

FXML: Why It Rocks, And The Next Phase

JavaFX 2.0 shipped with a declarative XML-based language for defining user interfaces, called FXML. FXML is a key part of our strategy around making it easier to create user interfaces in Java. Certainly having a markup language has been attractive to web developers since it is a familiar and comfortable way to approach describing a user interface. But there are other key strategic reasons why FXML is important, how it fits into the broader JavaFX ecosystem, and how it helps you write testable user interfaces with minimal fuss. In essence, FXML helps you follow best practices while also making your life easier.

(more…)

JavaFX sessions at JavaOne 2011 online

The audio + slides for many of the JavaFX sessions at JavaOne 2011 are available on parleys.com. I have embedded a few we recommend you watch. There will be more arriving on parleys.com over the next couple weeks as they get processed.

Introduction to JavaFX :: Nicolas Lorain

JavaFX Architecture :: Richard Bair

JavaFX Architecture II :: Richard Bair

Don’t use impl!

I was just working my way through the last few days of posts on the JavaFX OTN forums and noticed somebody who was trying to learn how to write a custom layout pane and included the following code in the forum posting:


public class MyLayout extends Pane {
@Override protected void layoutChildren() {
// TODO
}

@Override protected void layoutInArea(Node arg0, double arg1, double arg2,
double arg3, double arg4, double arg5,
HPos arg6, VPos arg7) {
// TODO
}

@Override protected void impl_layoutBoundsChanged() {
// TODO
}
}

This reminded me that I had failed to write a blog warning of the perils of using impl_ methods in JavaFX 2.0. DON’T EVER USE THEM!!

(more…)

JavaFX 2.0 Released

Whoa! It is kind of embarrassing that we haven’t yet blogged about the fact that JavaFX 2.0 has been released! In our defense, it has been a very busy past few days. At the JavaOne Technical keynote Monday morning I announced 4 things:

  • GA Release of JavaFX 2.0 (32 bit XP, 32 & 64 bit Windows Vista and Windows 7)
  • Developer Preview release of JavaFX 2.0 for Mac OS X
  • Early Access (for partners) of JavaFX Scene Builder (RAD tool)
  • Netbeans 7.1 Beta with support for JavaFX

In addition, on Tuesday Adam Messinger (VP Java SE, Java Client, Java ME — my bosses boss) announced that we are open sourcing all of JavaFX. We are asking the OpenJDK community for a new project where we will put JavaFX. In addition, we will be working with the JCP to propose JavaFX as an official standard part of the Java platform (probably targeted for Java 9).

There was also a very exciting demo which you probably have already seen, where Nandini Ramani (VP Java Client, my boss) showed JavaFX running on both a Samsung Galaxy Tab (atop Android) and an iPad. Needless to say, this has generated quite a bit of buzz. I’ll blog separately about how this works and why (I gave a session on the subject on Tuesday).

We’ll also be blogging with our slides from the conference. In the meantime, the conference is ongoing, and I’m late for a session I wanted to attend. I’ll also post some slides from the Monday Keynote and Tuesday keynote (if I can get my hands on them)

JavaFX links (for the past few days), September 30

Here’s a special edition of Java desktop links for folks. I thought, given the fact I’ve accumulated a few good links this week already, and that I’ll be super-busy next week and probably won’t be able to share any links, that I’ll get a post out before I fly out to JavaOne. Enjoy 🙂

  • Mean words are being said, battle lines are drawn, and full-on war is nearing…at least in the vicious GroovyFX vs ScalaFX battle for minds and hearts. Stephen Chin started it with his post introducing ScalaFX. He may not have said it, but I’m sure you could tell he was suggesting that ScalaFX was the better choice over GroovyFX….
  • Naturally, Dean Iverson wasn’t going to take this lying down, so he fired up his blog and posted a stinging GroovyFX rebuttal.
  • Backing Dean was Jim Clarke, co-developer of the GroovyFX library along with Dean. Jim has just started a series of blog posts on getting started with GroovyFX.
  • Of course, I’m sure both Stephen and Dean are toiling away on their own implementations. They’ll be meeting head-to-head for a winner-takes-all battle at their JavaOne session next week: ‘JavaFX 2.0 with Alternative Languages’. Unfortunately, this session conflicts with a session I’m giving on ‘JavaFX Data Sources’, but alas, I’m sure you’ll all make the right call.
  • Speaking of the JavaFX Data Sources talk I am co-presenting with Johan Vos, we just put up a website for the related project: DataFX. It is two projects in one: a series of data source adapters to make bring data into JavaFX UI Controls simpler, and a number of pre-built cell factories to make rendering data simpler and richer. Downloads will be enabled next week once we’ve presented our talk.
  • Final warning: next week Peter Pilgrim will be presenting his ‘Progressive JavaFX 2.0 Custom Components‘ JavaOne talk at the Silicon Valley JavaFX Users Group. It’s on Thursday, October 13, 2011, at 6:00 PM. As per usual, it’ll be live streamed for those that can’t attend in person. For the first time, I’m hoping to finally be able to attend in person this month.
  • Tom Schindl has put up a blog post on ‘How to author FXML‘, which demonstrates some work he has done to make developing JavaFX interfaces simpler in his e(fx)clipse project.
  • In another post, Tom has just announced the release of e(fx)clipse 0.0.6. This release incorporates the FXML authoring support mentioned in the previous link, as well as updated CSS support, improved OSGi bundling support, and the beginnings of runtime components (including layout APIs and OSGi support).

Ok, that’s it for this week. I apologise in advance for any lapses in links postings for the next few weeks. I’ll try my best, but I’m really hoping you folks make it easier for me by emailing me any new and wonderful links you may find. Also, as I said last week, I’m really looking forward to catching up with you all next week at JavaOne. If you see me, please come up and chat – the hallway track is by far the most fun part of JavaOne.

Until next time, have a great week, enjoy JavaOne, and I’ll see you on the other side! 🙂

JavaFX links of the week, September 26

Here we are: one week to go until JavaOne starts. There are a number of links this week, but I’m sure there will be a lot of good news coming in the next few weeks. I’ll try my best to get blog posts out whilst I’m traveling, but I can’t guarantee it. I’m away for three weeks from October 1 to October 23.

For those of you coming to JavaOne, I’m really looking forward to catching up with you – if you spot me please come up and chat! 🙂

Catch you all at JavaOne, or in another links roundup as soon as I can create it! 🙂

JavaFX links of the week, September 19

Another week, and a lot of good links. Not long now until JavaOne, when I’m sure there will be plenty of interesting news coming out. Let’s get into the news.

  • JavaFX 2.0 beta b45 came out this week. Grab it while it’s hot.
  • The JavaFX documentation team is doing a great job of tracking what is changing between beta builds, and keeping you in the loop. Find out what changed in b44 and b45 over at the JavaFX documentation blog.
  • The Silicon Valley JavaFX Users Group has a session the week following JavaOne, on Thursday, October 13. This month the presentation is by Peter Pilgrim, repeating a presentation he is also giving at JavaOne. The talk is titled “Progressive JavaFX 2.0 Custom Components“. For the first time, I’ll be able to attend in person, and given that this session talks about custom controls, it’s right up my alley. For those of you who can’t  be there in person, remember it is also live-streamed via UStream.
  • Dean Iverson tweeted that he has released version 0.2 of the Griffon JavaFX 2.0 plugin.
  • The in-development NetBeans 7.1 contains much greater support for JavaFX 2.0, including support for FXML, CSS3, preloaders, and project configuration.
  • Randahl Fink Isaksen, a frequent and valuable reporter of JavaFX 2.0 bugs, has written a post titled “JavaFX eats HTML UIs for breakfast“.

That’s that for another week. Hope you all found something useful! 🙂

JavaFX links of the week, September 5

Here we go, yet another weeks worth of JavaFX links. There are quite a few interesting links this week – so tuck in and enjoy! 🙂

That’ll do for another week I think. Catch you all in a weeks time. Keep up the hard work folks! 🙂