Devoxx 2008 University Monday JavaFX Launches

DZone 's Guide to

Devoxx 2008 University Monday JavaFX Launches

· Java Zone ·
Free Resource
Welcome to the first blog issue of the Devoxx 2008 conference, which was originally titled JavaPolis, but because of commercial trademark issues with Sun Microsystems, it had to be renamed. It is a longer story. Most gratefully, Stephan Janssen, organiser and co-founder, really does a very fine job getting this massive European Java conference trucking through every single December. He is a truly great Java Champion for his herculean efforts, which I tell you, should not be underestimated. Devoxx is sold out, it is expected that 3200 people from all over the world will be stepping through the Metropolis door.

I bumped into Aaron Houston, who related a lot of changes that are going on a Sun Microsystems. Most of this you already know. Sun announced a major redundancies and there have been business restructuring across the board. If this worries you, then please rest assured that every large company, especially the mult-national ones go through revitalisation. This is change and it is evitable.

Shout Outs!

Louis Emmett, JAVAWUG speaker and member. You finally made to Java conference. Well done that man!
Aaron Houston, Sun Technology Outreach team
Carole McDonald, Sun Technology Outreach team
Michael Huettermann, Java Champion, Cologne JUG
Dave Booth, soon to be an ex-JetBrainer
Bruce Synder, the one and only
Kirk Pepperdine, Keepin' on Tuning This.
Marco Van Beelen, JAVAWUG Belgium member!
Joshua Marinacci, JavaFX Team Member
Ilya Sergey, NetBrains software engineer

(Top and right photographs courtesy of Aaron Houston)

In the last two weeks before Devoxx I was considerably time challenged, but I did upload to Vimeo the very last Java Champions BOF from JavaOne.

JavaOne 2008 Java Champions BOF from peter_pilgrim on Vimeo.

JavaFX Media Playing Problem

Here is example code for a JavaFX 1.0 media player that does not work with NetBeans 6.5 !

// MediaPlayerTestOrig.fx
package fxexamples;

// http://www.jhepple.com/support/SampleMovies/WindowsMedia.wmv

import javafx.scene.paint.Color;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.ext.swing.SwingSlider;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import javafx.ext.swing.SwingButton;
import javafx.scene.Scene;
import javafx.scene.transform.Transform;
import java.lang.System;
import javafx.stage.Stage;
import javafx.scene.text.Text;
import javafx.scene.text.Font;


var playButton: SwingButton;
var pauseButton: SwingButton;
var stopButton: SwingButton;
var timeSlider: SwingSlider;


var media = Media {
        source: "{__DIR__}videos/movie.avi"
        // source: "{__DIR__}videos/WindowsMedia.wmv"

var myCurrentTime: Duration on replace {
    //    FX.println("myCurrentTime={myCurrentTime}");
    if ( not timeSlider.enabled) {
        timeSlider.value = myCurrentTime.toMillis() as Integer;

var sliderValue: Integer on replace {
    if ( player.status == player.PAUSED ) {
        player.currentTime = sliderValue * 1ms ;

var player = MediaPlayer {
    media: media
    autoPlay: false
    currentTime: bind myCurrentTime with inverse;
var view: MediaView;

var stage:Stage = Stage {
    title: "Peter Pilgrim's JavaFX Example Video Player";
    visible: true;    
    width: DEFAULT_FRAME_WIDTH as Integer;
    height: DEFAULT_FRAME_HEIGHT + 100 as Integer;

    onClose: function() {
        java.lang.System.exit( 0 ); 

    scene: Scene {
        fill: Color.WHITE
        content: VBox {
            spacing: 10
            content: [
                view  = MediaView {
                    mediaPlayer: player
                Text {
                    font: Font {
                        size: 24
                    x: 10,
                    y: 30
                    content: bind "{%6s player.currentTime.toString()}"
                HBox {
                    content: [
                        playButton = SwingButton {
                            text: "Play"
                            action: function(): Void {
                                timeSlider.enabled = false;
                        pauseButton = SwingButton {
                            text: "Pause"
                            action: function(): Void {
                                timeSlider.enabled = true;
                        stopButton = SwingButton {
                            text: "Stop"
                            action: function(): Void {
                                player.currentTime = 0s;
                                timeSlider.enabled = true;
                        timeSlider = SwingSlider {
                            minimum: 0
                            maximum: bind
                            media.duration.toMillis() as Integer
                            vertical: false
                            enabled: true
                            value: bind sliderValue with inverse;


System.out.println( "media.width={media.width}" );
System.out.println( "media.height={media.height}" );
System.out.println( "media.duration={media.duration}" );
System.out.println( "player.currentTime={player.currentTime}" );
// End.

Actually the problem is that Java Media Component (JMC) fails to read JAR file type URLs of the type.

generating HTML applet page
Error with Media: MediaError: media unsupported:com.sun.media.jmc.MediaUnsupportedException: Unsupported media: jar:file:/C:/Users/Peter/Documents/NetBeansProjects/FXExamples/trunk/dist/FXExamples.jar!/fxexamples/videos/movie.avi
MediaComponent CREATED
Error with MediaPlayer: MediaError: media unsupported:com.sun.media.jmc.MediaUnsupportedException: Unsupported media: jar:file:/C:/Users/Peter/Documents/NetBeansProjects/FXExamples/trunk/dist/FXExamples.jar!/fxexamples/videos/movie.avi
BUILD SUCCESSFUL (total time: 20 seconds)

Now for a workaround. In your Ant build.xml project file, override the "standard-run" target, so it does not execute against a JAR file, but rather the classes instead. This target works for NetBeans 6.5 until the JavaFX / JMC teams fix the bug.

<target depends="init,compile,jar" description="Run a main class. (PP)" if="standard.execution.trigger" name="standard-run">
        <java classname="${main.class}" classpath="${basedir}/build/compiled:${basedir}/lib/mediacomponent.jar" failonerror="true" fork="true" jvm="${platform.fxhome}/bin/javafx${binary.extension}" jvmargs="${run.jvmargs}"/>


JavaFX in Practice, University Morning

Richard Bair, Jasper Potts and Martin Brehovsky

This session was introduction into the scenegraph of JavaFX. The graphics rendering UI framework that was created as part of JavaFX. Richard Bair and Jasper Potts headed up this portion. There were nifty demonstrations of animation and the JavaFX media player. The brand new transitions were also very interesting as these to the similar path work yours truly did on Project Goliath:
JavaFX BOF: Bring JavaFX and Designers Together with Project Nile

Martin Brehovsky hosted a special BOF session at 7pm at Devoxx, which was well attended, where he presented again the aspects of Project Nile: The JavaFX Production Suite for Designer. He showed a lot of examples from JavaOne, including the invaders game. By altering the asset of a cloud or a space invader graphic in Adobe Illustrator, it was easy to pick this changes up in NetBeans 6.5. He confirmed that JavaFX Scenegraph 3D is coming along, but he could not give a date. The same idea of a production suite for designer would probably be coming to 3D designers and developer. He could imagine a plug-in export for Maya, for example, or 3DMax. We will have to wait and see in 2009 what exactly Sun JavaFX team decides to do. Martin did say that he would like to support a plug-in for Adobe Flash and more importantly for him to support animations and timelines in the designer and developer workflow. Now 3D support and also animation support would be very cool and impressive if you used to design in Flash in the old fashion way with timelines and movie assets instead of nowadays with a shed load of ActionScript way. Think circa (Macromedia Flash MX 2004 ;-).

  • ScaleTransition
  • TranslationTransition
  • RotateRotation
  • FadeTransition
  • SequenceTransition
  • ParallelTransition
  • ComplexTransition

We got some official details on the progress of JavaFX.

Java FX 1.1. release around February 2009
Java FX 1.5 release around June 2009
JavaFX 1.0 Production Suit allows the of use professional graphics in your application.
Richard Bair said, hopefully, the FX 2.0 beta will be coming along in the latter half of 2009.

Yours truly talked with Joshua Marinacci, it appears that maybe we might have a couple of GameKit implementation, which includes another guy, to compare and contrast, may be even an open source project. I had real trouble getting the media inside NetBeans for work. It was good to confirm in this university session that rich media does work.

Martin Brehovsky demonstrated the production suite part of JavaFX. Whilst, claiming he was no UI designer. He showed how a designer, could save a Adobe Photoshop graphic as JavaFX design file, which he imported into NetBeans 6.5. The assets where available to the developer as look ups. This is a very cool idea, because almost every professional and freelance designer chooses to use Adobe Illustrator or Photoshop.

Introduction to Google Android,

Romain Guy

Guy showed us the software development on the Android by going through an overview of the Android tools. He spent time explaiining the concept of Dalvik byte codes. He talked about why did Google prefer to create its byte code interpreter. Romain Guy provided an overview of the platform, the IDE (which he claimed does not use at all) and other tools.

The content was a little dry for my understanding, but it is a complex platform for those who want to really develop for the G1 Mobile phone. For these people then this session was very important. Romain Guy showed very cool demonstration of the Android emulator. As a well known keen photography nut, he demonstrated a mobile application, which he developed, called PhotoStream, a sample photo sharing application, which retrieved images from Flickr. He covered disparate Android topics such as Activities, Intents, Categories and Action events. All of his example were completed under the guidance of the Eclipse SDK Android Plug-in.

He also talked about graphical layouts available on the Android, which I think are missing on the JavaFX 1.0 scenegraph.

  • FrameLayout
  • Linear Layout
  • RelativeLayout
  • TableLayout
  • AbsoluteLayout (he deprecated this one, right there and then)

One of interesting part of note to other mobile platform were the Service APIs. Guy described services as faceless components that run in the background. This feature alone will probably attract the attention of iPhone developers, because it means that background threading or processing is at least probable and better implemented in Android. For example, Romain Guy said that the background service provider in Android could be a music player, network download, etc. You can bind your code to a running service, via an IDL (Interface Definition Language). Content Providers enable sharing of data across applications. Examples of providers are call list, address book, photo gallery, etc. Actually, I thought Android, was a nice development for. Every facility has a security permission, which means that malicious application should not be able to attack the caller list and upload it to a spammer. Google has taken off this and therefore it looks very well thought out, and the Eclipse Debugging looks familiar. There are laudible advantages to build mobile phone application with Android. It is not completely open source, but there is a mobile phone device out there for it. I am sure there will be more. I just feel that Android is about 6 months behind iPhone in development community terms. Also, the fact that a community guy, ported JavaFX last year to it, was wso onderful. The key takeaway for Android, were that the system takes care of the lifecycle of an application. The start and stop is transparent to the user. The end-user only sees that they are moving between screans. Guy pointed us to read the documentation for android.app.Activity.

Guy gaves these limitiation sfor (typical) phone development

  • Resources are typically very limited in a mobile phone in comparison with a desktop PC
  • The CPU typically run much slower than their desktop counterparties. Slow CPU (~380mhz to preserve battery life)
  • Slow RAM in order to perserve battery life)
  • Very little RAM (~80MB on G1)
  • Very little storage (~55MB on the G1)

Al Coda

JavaFX really got its first development annoucement at the Devoxx 2008 conference, even though it was realised last week (4th December 2008). The fact that Java on the client-side can play video and audio files natively is absolutely brillaint. Why did Sun not do this in 2005? If they did, it really would have changed the game of RIA and of course the direction of the AJAX toolkits. The planets have to align up. But yours truly is not one to rest on what could have been in the past. JavaFX 1.0 is here now, with some minor niggles, and there are still going to be many detractors. As for me, JavaFX is now a welcome addition to my tool box, it is a framework and new platform, to build exciting new software on. It has already rekindled an interest in user interface, especially games, which I have long had, after Java Swing in 1999 and 2000. I worked even back in the earlier days of X Windows / OSF Motif, you should look that C/C++ framework, compare and contrast on how far we have innovated. JavaFX is progess and thank goodness for Sun Microsystems it does feel good. 

This is Peter Pilgrim at Devoxx 2008. Out

From http://www.jroller.com/peter_pilgrim


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}