Thursday, July 31st, 2008

JavaFX: The preview has landed

JavaFX was announced at JavaOne…. in 2007, and we are now seeing a preview release.

Josh Marinacci of the JavaFX team put together a post with an example that builds the following:

The code for this is simply:

  1. package blogdemo;
  3. import javafx.scene.*;
  4. import javafx.scene.paint.*;
  5. import javafx.scene.geometry.*;
  6. import javafx.application.*;
  7. import javafx.scene.transform.*;
  8. import javafx.input.*;
  9. import javafx.animation.*;
  10. import java.lang.System;
  12. var angle = 0.0;
  14. Frame {
  15.     windowStyle: WindowStyle.TRANSPARENT  visible: true
  16.     width: 400 height: 400
  17.     stage: Stage {
  18.         fill: null
  19.         content: Group {
  20.             translateX: 100 translateY: 100
  21.             content: for(i in [0..10]) {
  22.                 // here is the magic with binding
  23.                 Rectangle {
  24.                     fill: Color.rgb(25*i,0,0, i/10.0)
  25.                     width: 100 height: 100 arcHeight: 10 arcWidth: 10
  26.                     stroke: Color.BLACK strokeWidth: 5
  27.                     transform: bind [
  28.                         Transform.rotate(-i*36+angle/2,50,50),
  29.                         Transform.translate(angle/4,0),
  30.                     ]
  31.                 }
  32.             }
  33.             onMousePressed: function(e:MouseEvent):Void { System.exit(0); }
  34.         }
  35.     }
  36. }
  38. var anim = Timeline { keyFrames: [
  39.         KeyFrame { time: 0s values: angle => -360 tween Interpolator.EASEBOTH },
  40.         KeyFrame { time: 2s values: angle => 360 tween Interpolator.EASEBOTH },
  41.     ]
  42.     autoReverse: true
  43.     repeatCount: Timeline.INDEFINITE
  44. };
  45. anim.start();

And you can check out the application if you have Java 1.6 installed.

Michael Coté got together with the Sun folks and recorded a demo and interview:

I am interested to see what Sun does with JavaFX, but I have to admit to being underwhelmed and more excited about what Sun could do with the Java plugin and have that as a way to interact with Ajax applications.

Posted by Dion Almaer at 10:51 am

2.8 rating from 35 votes


Comments feed TrackBack URI

Seems like someone who wants to use Java in the browser would lean more toward GWT (which doesn’t require a plugin). But I suppose it depends on exactly what you want to do and how you want to work.

Comment by Nosredna — July 31, 2008


GWT supports only a limited subset of Java and is limited to the Browser’s scripting engine. JavaFX (or Java), with proper support and plugins, could theoretically support anything in the JRE (running in a sandbox, of course) – including accelerated graphics, sockets, and more.

I’d be interested in seeing a more stable Java plugin, and more intuitive ways to interact with the DOM or Javascript.

Comment by matanlurey — July 31, 2008

meh… I want to see something that interacts with and is far more integrated into the browser and the DOM. this example leaves much to be desired, and given Silverlight is leaps and bounds past this, and Adobe AIR and Flash are farther still, and part of 90+% of all browsers, JavaFX has a long way to go, and some serious catching up to do…

Unfortunately, this is more of the same from Sun lately… too little, too late. Sun should concentrate all efforts on J2EE 6 and stop worrying about this market which is already dominated by others.

Comment by PuckPuck — July 31, 2008

underwhelmed is an understatement…

Comment by constantology — July 31, 2008

In the video, she is using a 6u10 feature (applet dragging) on OSX. Anyone know how to get that working on OSX without waiting for Apple to release their version of 6u10?

Comment by jaydfwtx — July 31, 2008

@jaydfwtx: I believe in the latest update to the JDK by Apple it goes to 1.6 but it’s only for the latest 64bit Intel Mac’s :( no 32bit Intel or PPC.

Comment by fighne — July 31, 2008

I can’t download the Java update, I’m in an embargoed country – Canada!
* sigh* what did we do this time?

Comment by Diodeus — July 31, 2008

>>GWT supports only a limited subset of Java and is limited to the Browser’s scripting engine.

Yeah, but I don’t even install Java anymore. :-)

Comment by Nosredna — July 31, 2008

You win that round Nosredna.

Comment by matanlurey — August 1, 2008

certainly is awesome, although i think canvas may give javafx a run for it’s money.

Comment by indiehead — August 1, 2008

>>You win that round Nosredna.
The amazing thing is, the web seems dead if you try it without Flash, but works just fine without Java. I don’t feel like I’m missing much of anything except for ads. Maybe if Flash had never shown up, Java would be more important in the client.

Comment by Nosredna — August 1, 2008

@fighne That is true, but not what I asked. I currently have Java6 on my mac, but it is 1.6_05… 6u10 is not out for macs yet. Since the draggable applet feature comes in 6u10, and she is showing it on a mac, then they must have a special build they are using or they have hacked it to work somehow.

Comment by jaydfwtx — August 1, 2008

Apart from a performance gain, I don’t see any reason not to do this with the Flash Authoring environment and Actionscript 3.

Kudos thought for the feature that allows the app to run locally by simply dragging it outside of the browser window.

Comment by nicolasschudel — August 3, 2008

Thats not as exciting as the title suggests.
However, Intresting never the less

Comment by Remedies — November 19, 2008

Leave a comment

You must be logged in to post a comment.