JavaFX 1.2 Technology: Features and Enhancements

 

The JavaFX 1.2 SDK is a significant update to the JavaFX 1.1 SDK. The JavaFX 1.2 SDK includes changes to the APIs that are not forward compatible. Some classes, APIs, and variables have been removed from the JavaFX 1.1 SDK, while newer classes, APIs, and variables have been added to the JavaFX 1.2 SDK.

The JavaFX 1.2 SDK release is not binary compatible with the JavaFX 1.1 SDK. This means that your application and all libraries that it depends on must be recompiled with the JavaFX 1.2 SDK.

Legend (Added: Add icon, Removed: Remove icon, Changed: Changed icon)


Animation

Packages affected: javafx.animation, javafx.animation.transition

  • Transition.interpolate is now named interpolator. Changed icon

    Old: public override var interpolate = Interpolator.LINEAR; New:   public override var interpolator = Interpolator.LINEAR;
  • The Transition class inherits from the Timeline class. Changed icon
  • The Transition.duration variable in SequentialTransition and ParallelTransition is inaccessible. However, the public-read protected variables cycleDuration and totalDuration are now included in the Timeline. Remove icon Add icon

    public-read protected var cycleDuration: Duration
    public-read protected var totalDuration: Duration
  • The timelines variable is no longer included in KeyFrame. Subtimelines are no longer supported. This functionality is now supported by ParallelTransition and SequentialTransition. Remove icon
  • The timelineDirty variable is no longer included in the Transition class. The markDirty() function provides the same support as the old timelineDirty variable. timelineDirty, previously a protected variable of the Transition class, is now a local variable and can be modified through a protected markDirty() function in the Transition class. This change enables a third-party library to extend the JavaFX Transition base class to implement additional Transition classes. The existing Transition classes, such as TranslationTransition, RotateTranslation, and PathTransition, work as before. Rename

    Old: timelineDirty = true; New:   markDirty()

Asynchronous Operations

Package affected: javafx.async

  • The AbstractAsyncOperation and RemoteTextDocument classes are no longer included in the javafx.async package. The javafx.io.http.HttpRequest class can be used instead of the javafx.async.RemoteTextDocument class. Remove icon
  • The following classes are new to the javafx.async package. Add icon


Effects

Package affected: javafx.scene.effect

  • The following classes are new to the javafx.scene.effect package. Add icon


Graphics

Packages affected: javafx.scene.transform, javafx.scene.image, javafx.ext.swing, javafx.scene, javafx.scene.layout, javafx.stage, javafx.geometry, javafx.scene.paint

  • The variables for the matrix elements in the javafx.scene.transform.Affine class are now named as follows: Changed icon

        m00 --> mxx
    m01 --> mxy
    m02 --> tx
    m10 --> myx
    m11 --> myy
    m12 --> ty

    However, the more common use case of using the Transform.affine method is not affected.

    Old: Affine { m00: 1 m10: 0 m01: 0 m11: 1 m02: 25 m12: 15 } New:   Affine { mxx: 1 myx: 0 mxy: 0 myy: 1 tx: 25 ty: 15 }
  • javafx.scene.image.Image.fromBufferedImage(image:java.awt.image.BufferedImage) is now named javafx.ext.swing.SwingUtils.toFXImage(image:java.awt.image.BufferedImage). The parameters and functionality are identical to the old method. Changed icon
  • The javafx.scene package supports the following new classes: Add icon


  • The javafx.geometry package supports the following new classes: Add icon


  • No events should be delivered when Node is disabled. Changed icon

    • An application should not expect events on a disabled Node.
    • Mouse and key event handlers should not be invoked when Node is disabled.
    • A focused Node should lose focus when it becomes disabled.

  • The enabled variable of Swing components in the javafx.ext.swing package is no longer included. The disable variable is still available and sufficient to handle the enabling and disabling of components. Remove icon
  • New layout variables are now included in javafx.scene.Node, javafx.scene.CustomNode, and javafx.scene.Group: Add icon

    • layoutInfo
    • layoutBounds
    • layoutX
    • layoutY
  • The preferred method to position a node for layout is layoutX and layoutY instead of using translateX and translateY. While translateX and translateY most likely will work, layoutX and layoutY will have better performance. Also, if you do a legitimate translateX and translateY, the original value is lost if you did not use layoutX and layoutY. Add icon
  • The default layoutBounds of a Node does not include clip, its effect, or any of its transforms. Rename
  • The implicit pivot of a Node when using the scaleX, scaleY, or rotate variables is the (untransformed) center of the layoutBounds. Rename
  • The boundsInScene variable is no longer included in the Node, Group, and CustomNode classes. The localToScene(boundsInLocal) function provides the same support as the old boundsInScene variable. The boundsInScene variable was expensive to compute, and the localToScene(boundsInLocal) function gives better performance because binding to the localToScene function is not allowed. Rename

    Old: node.boundsInScene New:   node.localToScene(node.boundsInLocal)
  • The javafx.scene.layout package now includes the following classes. Add icon


    Please see What's New in JavaFX 1.2: New Layouts and Effects for more information.

  • A new Boolean public-read protected variable needsLayout is inherited from the javafx.scene.Parent class in the ClipView, Flow, Panel, Stack, Tile, HBox, and VBox Classes. Add icon
  • The javafx.scene.layout packages, HBox and VBox, now support positioning of the node within the allocated space by using nodeVPos and nodeHPos respectively. Under JavaFX SDK 1.1, all nodes were positioned at the top for HBox, and to the left for VBox. Changed icon
  • In the javafx.scene.layout.Resizable class, the preferredHeight and preferredWidth variables are no longer included in the Resizable class. The getPreferredHeight() and getPreferredWidth() functions provide the same support as the old preferredHeight and preferredWeight variables. preferredHeight and preferredWidth are now local variables and can be accessed through the protected getPreferredHeight()and getPreferredWidth() functions in theResizable class. Rename

    Old: public-read protected preferredWidth: Number New: protected override bound function getPreferredWidth(): Number Old: public-read protected preferredHeight: Number New: protected override bound function getPreferredHeight(): Number
  • In JavaFX SDK 1.1 the bounds of an invisible child of a Group (that is, a child node with visible: false;) was included in the bounds of the Group. In JavaFX SDK 1.2, any invisible children do not contribute to the bounds of its parent Group. If you want this behavior, set the child node to (visible:true; opacity:0;).Changed icon

  • The following classes are new to the javafx.stage: Add icon

  • The new Screen class causes the javafx.screen.width and javafx.screen.height properties to become obsolete. The javafx.screen.width and javafx.screen.height are no longer supported from javafx.FX.getProperty(). Remove icon
  • The Screen class also includes a dpi property for querying both the screen size and resolution (DPI). Add icon
  • The focused variable in the javafx.stage.Stage class is now named containsFocus. Changed icon
  • It is illegal to use a node in more than one place in any of the following: in the content sequence of a Group, as the clip of another node, or as the return value of the CustomNode.create() function. If the JavaFX 1.2 runtime detects an attempt to use a node in more than one place, it will throw an exception and ignore the attempt, except as noted below. Changed icon

    Previous releases of the JavaFX technology explicitly allowed a node to be inserted into the content sequence of a Group, even if the node was already a member of the content sequence of another Group. If this occurred, the node would implicitly be removed from the other Group. In the JavaFX 1.2 runtime, adding a node to a Group while the node is already a member of another Group is now considered illegal, as it is most likely a programming error. However, the implicit removal behavior is preserved, and a warning message and exception stack trace will be printed, in order to provide a transition period for existing code.
  • It is common to fetch named nodes from content loaded from an FXZ file created by the JavaFX Production Suite, and to place these nodes into new Groups. Changed icon

    var fxdContent = FXDLoader.loadContent("scene.fxz"); 
    var g = Group {
    content: [ fxdContent.getNode("myNode") ]
    }

    This code will generate a warning message in JavaFX 1.2 because the node retrieved from fxdContent is already a member of a Group created FXDLoader. To avoid this warning message, remove the node from the old Group before adding it to the new one. If you are using nodes loaded from an FXZ file, you can use the javafx.fxd.Duplicator class to copy nodes instead of moving them. Or, you can rearrange the structure of the artwork and regenerate the FXZ file. Avoid doing scene graph manipulations after loading the FXZ file.
  • The fromAWTColor method is no longer included in the javafx.scene.paint.Color class. Remove icon
    public fromAWTColor(c: java.awt.Color) : Color 
  • The enabled variable has been removed from the javafx.ext.swing.SwingComponents class. Remove icon

Keyboard and Mouse Events

Packages affected: javafx.scene.control, javafx.ext.swing, javafx.scene.input

  • Node is not focusable by default and the key handler is not required for Node to become focused with two exceptions: Control and SwingComponent are focusable by default. The new focusTraversable variable is now included, and it is a Boolean. The focusTraversable variable specifies whether this Node should be a part of a focus traversal cycle. Changed icon Add icon
  • A new source variable Node is now included in the MouseEvent class for event bubbling. The source variable is visually the topmost node in the node subtree under the mouse event. In the case where the node is a leaf node, the source variable is the same as the node. In the case where the node is an instance of the Parent, the source variable is visually the topmost node in the (@node) subtree under the mouse event. Add icon
  • The javafx.scene.input package now includes the following classes. Add icon


Language Changes

 

  • Please refer to the JavaFX Script Programming Language Reference.
  • Multiple inheritance: In JavaFX 1.1, a JavaFX class could inherit from classes and interfaces, with a complex rule about which classes could be inherited. In JavaFX 1.2, the concept of a mixin class has been added. Inheritance rules now include mixins and as a result are simplified and slightly restricted. A JavaFX class may now inherit from no more than one (non-mixin) class, and any number of interfaces or mixins. A mixin cannot be instantiated directly. Mixins look like regular classes, but have the mixin modifier on their declaration. For more information, see the JavaFX Language Tutorial.
  • A comma is now required in explicit sequences: Changed icon

    [3, 77, 8]

    But, like a semicolon, a comma is not required after }:

    [Foo { 
    x: 14
    }
    Bar {
    sneeze: "cough"
    }
    ]
  • The precedence of the or operator and the and operator is changed. The JavaFX and operator now has higher precedence than the or operator. Changed icon

       a or b and c   

    is equivalent to:

       a or (b and c)

  • A var in a block cannot have the same name as a var in a containing block. The following are now disallowed: Changed icon
  • public function f() {
    var x : Integer;
    {
    var x : Integer; //compile error
    }
    }

    Or

    for(i in [1..5]) {
    for(i in [2..4]) { //compile error
    println("Test");
    }
    }
  • The on replace trigger is no longer allowed inside bind. Changed icon

    var x = bind for (i in [0..5]) {
    var y = (i mod 2 == 0) on replace { //compile error
    println("y changed");
    }
    y
    }

  • Bound for-loops over Iterable are no longer allowed because they do not make sense and updates are not seen. Changed icon
  • Changes to Duration include the following: Changed icon

    • Duration.toMillis() returns Double instead of Number.
    • Duration.INDEFINITE now represents a time period of unknown length.
    • Duration.toDate() is no longer supported.

  • A number of reserved words are no longer formally reserved and can be used as identifiers: Changed icon

    • first
    • in
    • init
    • into
    • inverse
    • last
    • on
    • postinit
    • replace
    • step
    • trigger
    • tween
    • where
    • with

 

Media

Package affected: javafx.scene.media

  • Real-time streaming protocol (RTSP) support is new. You can read more about RTSP on the RTSP wiki. Add icon

    var url: String = "rtsp://sqe-macpro-2.sfbay.sun.com/sample_300kbit.mov";

  • Media supports two more OS platforms, OpenSolaris and Ubuntu Linux. Both platforms use the open source multimedia framework GStreamer. Add icon
  • Media has better support for video scrubbing. Add icon


Mobile

  • Mobile now supports rectangular clipping. Add icon
  • Cross-platform video (VP6 encoding) is supported, and FXM/VP6 is now included. Add icon
  • The Mobile Emulator (Windows platform only) supports additional media files: Add icon

    • FXM/FLV, WAV and MIDI files are now supported by default and no third-party components are needed.
    • For MP3 and AMR files, you must install the appropriate DirectShow filters (a splitter and a decoder). For example, the K-Lite Codec Pack contains all necessary filters.
    • For 3GP, MPEG1, MP4, MOV files, you must install the Apple QuickTime player. If any of these formats do not work, reinstall the Apple QuickTime player and restart your computer.

Performance Improvements

  • The underlying implementation of scene graph refactoring provides better runtime performance. Changed icon
  • Startup-time performance is an improvement over previous startup-time performance. Changed icon
  • The compiler changes provide better runtime performance. Changed icon
  • Please refer to the article on Performance Improvement Techniques for JavaFX Applications.


Persistence Storage

Package affected: javafx.io

  • A new javafx.io package now includes the following classes. Add icon


Platform Support

  • Support is now provided for two additional OS platforms: Add icon

    • Solaris Beta: OpenSolaris 2009.06
    • Linux Beta: Ubuntu 8.04 LTE


Production Suite

Package affected: javafx.fxd

  • Support is now provided for Adobe Photoshop CS4 and Adobe Illustrator CS4. Add icon
  • In the javafx.fxd package, the FXDLoader class has additional variables and functions. The FXDLoader class inherits from the javafx.async.Task class to support the background loading of FXZ/FXD files. Add icon
  • The FXDNode class is added. The UiStub class is replaced with the FXDNode class. UI Stub files now extend from the FXDNode class. Add icon
  • The FXDNode class provides a choice of how graphics content is loaded: synchronous (which blocks other operations) or asynchronous (which runs in the background). Changed icon
  • Scene {content: FXDNode {           
    url: "{__DIR__}mygraphics.fxz"
    backgroundLoading: true
    placeholder: Text { x: 10 y: 10 content: "Loading graphics ..."}
    }
    }

  • The _root variable is no longer included in the FXDContent class. The getRoot() function provides the same support as the old _root variable. Changed icon


UI Control Components

Package affected: javafx.scene.control

  • The javafx.scene.control package now includes the following classes for creating UI controls. Add icon


  • Please refer to the article on JavaFX Scene UI Controls.
  • The Control is now an abstract class and changed significantly. Changed icon
  • The Behavior variable has been added to the javafx.scene.control.Skin class and removed from the focused, hover and pressed variables. Remove icon Add icon
  • The scene variable has been renamed to node in the javafx.scene.control.Skin class. Changed icon

    Old:
    public-init protected scene Node
    New:
    public-read protected node Node
  • The Skin class is now an abstract class and the new contains() and intersects()functions are added. The existing function names are changed as follows. Changed icon Add icon
  • Old: protected computeMaxHeight: Number New: protected getMaxHeight(): Number Old: protected computeMaxWidth(): Number New: protected getMaxWidth(): Number Old: protected computeMinHeight(): Number New: protected getMinHeight(): Number Old: protected computeMinWidth(): Number New: protected getMinWidth(): Number Old: protected computePrefHeight(width: Number): Number New: protected getPrefHeight(width: Number): Number Old: protected computePrefWidth(height: Number): Number New: protected getPrefWidth(height: Number): Number
  • The TextBox class has changed significantly and added new functionality. Changed icon Add icon

UI Chart Components

Packages affected: javafx.scene.chart, javafx.scene.chart.data, javafx.scene.chart.part


Web Services

Packages affected: javafx.io.http, javafx.data.pull, javafx.data.xml, javafx.data.feed, javafx.data.feed.atom, javafs.data.feed.rss

  • HttpRequest.enqueue() is now named HttpRequest.start(). Changed icon
  • HttpRequest.cancel() is now named HttpRequest.stop(). Changed icon
  • These two public functions are no longer included: Remove icon

    public function setHeader(name: String, value: String)
    public function getResponseHeaderNames(): String[]
  • The signature of these methods and fields changed from Integer to Long: Changed icon

    public-read protected var towrite: Long;
    public-read protected var toread: Long;
    public-read protected var written: Long;
    public-read protected var read: Long;
    public var onToWrite: function(bytes: Long): Void = null;
    public var onToRead: function(bytes: Long): Void = null;
    public var onWritten: function(bytes: Long): Void = null;
    public var onRead: function(bytes: Long): Void = null;

  • The URLConverter class is now included in the javafx.io.http package. Add icon
  • The new javafx.data.feed package includes the following two classes: Add icon


  • The new javafx.data.feed.atom package includes the following classes: Add icon


  • A new javafx.data.feed.rss package includes the following classes: Add icon


Miscellaneous

Packages affected: javafx.util, javafx.data