The Source for Java Technology Collaboration
User: Password:



John O'Conner

John O'Conner's Blog

Using JavaFX Script for UI Declarations

Posted by joconner on July 20, 2007 at 08:02 PM | Comments (6)

possible javafx logoThis is an exciting time for the Java platform for a lot of reasons, and certainly JavaFX Script is part of the buzz right now. If you read much about this new script language, you'll see lots of comments about how Sun is targeting this language for rich content development, a language to help us make our UIs sparkle. I think that opportunity is real, and I think JavaFX Script can help.

At least one argument for using JavaFX Script is its simpler syntax for content developers and UI designers. Personally, I don't think the procedural, algorithmic parts of the language are that much simpler than the Java language, but I do think the declarative UI syntax is easier, or can be easier, than Java. Reading the marketing literature for the language, I think the message includes an appeal to "non-programmers" and content creators. I don't know a lot of content developers or UI designers, but I'm going to go out on a limb and say that they probably aren't that interested in packages, class definitions, for-loops, operations, and maybe not even triggers. The UI declarations and UI definitions are going to be the most interesting to to a UI designer. Seems reasonable to me anyway.

My skills and interests aren't in UI design. However, I do want to know how a Java programmer and a UI designer would work together -- one using Java for the business logic, event handlers, and models, and the other using JavaFX Script to design only the UI and maybe a little animation here and there. Maybe that's not how the language designers intended it to be used; I don't know. But that's interesting to me. And if you can't use something for an unintended purpose, what good is it? OK, maybe that's not really true for programming languages, but my kids do seem to have a lot more fun jumping on the bed than sleeping on it. I'm digressing...

Unfortunately, I haven't yet found any demos or examples that show this sort of interaction with JavaFX Script. Instead, I see great demos -- absolutely fantastic, eye-popping demos -- that launch complete applications that have been written in the new language. That's great, but I want to pull back a few notches. I don't want to create my whole application in JavaFX Script just yet; I've spent too many years as a Java programmer. I have lots and lots and lots of Java code, complete with event handlers, listeners, models, etc. Although my application UI itself might benefit from a little scrubbing and a port to JavaFX Script, I don't want to port my whole application, at least not yet. I want to introduce JavaFX Script slowly, use it for the UI view only. I want to keep all my business logic, event handlers, and models in my Java code. Now that's what I'm interested in...for now at least. And, you know what, I think that's how many Java programmers would like to use JavaFX Script right now too. Hey, that's my opinion, completely unsubstantiated of course. Let's just say it's a feeling that I have -- an unendorsed feeling completely independent from Sun Microsystems*.

So for the next few blogs, that's where I'll turn my attention. I'm not going to write a complete application in JavaFX Script, but I am going to figure out how to access a declarative UI written in the scripting language. And I'll keep all my existing business logic and models and event handlers back where I'm comfortable...in the Java code. I hope my exploration helps someone else too. If I'm successful, you'll know; if I'm not, you'll know that too. If you have tips and more information, share them with me as I explore this language along with you.

*[Goofy disclaimer...just in case someone thinks I actually represent Sun in my personal blogs, I do not. Nothing in this post represents official statements of Sun Microsystems, although Jonathan Schwartz does call me from time to time asking for my opinion. Wait...he doesn't sell timeshares in Vegas or refinance home loans. Hmm...maybe that wasn't him on the phone. Never mind. As it turns out, all this is still just my independent opinion. ]


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • you can look http://www.oreillynet.com/onjava/blog/2007/05/javafx_first_steps_hello_onjav_1.html
    for a simple interactio between java and jfx

    Posted by: tharudan on July 21, 2007 at 07:05 AM

  • Quite off topic, but for the type of applications (whose main object is to provide a graphic front end to business logic) that you describe, I think the freeware Gola, a layout editor and code generator for Swing may be quite useful.

    Posted by: varan on July 21, 2007 at 12:00 PM

  • any idea about how to include external libraries in a JavaFX program ? is it possible ?

    I have tons of demos using Swing API and other Java API classes, but how can I use MyApi.JAR in a JavaFx project ??

    Posted by: felipegaucho on July 22, 2007 at 03:44 AM

  • > how can I use MyApi.JAR in a JavaFx project ??

    It's probably very simple. First you have to write a corresponding JavaFx interface marked with the keyword "native". Then you run javafxi which will generate a Java interface called JAVAFX_FX_INTERFACE_NAME. You will then have to implement this interface and it can call into your native Java code. In order to call back into JavaFX ...

    :-)

    Posted by: mernst on July 22, 2007 at 10:55 AM

  • This is exactly how we would use JavaFX as well. JavaFX would be the "view", and would be constructed entirely by a graphic designer/UI designer person/team. Everything else (the model, controller, services, etc) would be the realm of the software teams. Somehow, the two groups need to easily connect their pieces together. JavaFX (formerly F3) is still too alpha for us to use, but we would at least take the initial plunge of research if this kind of arrangement were made easy and obvious.

    Posted by: adepue on July 23, 2007 at 01:11 PM

  • Hey, by the way, thanks a lot for using my JFX logo ;-).
    For all interested in the logo, here you find more information and bigger sized logos: http://jfx.wikia.com/wiki/JavaFX_Logo_-_Centigrade
    - Would be cool to spread it... Thanks Flo.

    Posted by: flosweb on July 25, 2007 at 03:10 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds