JavaFX 1.2 Technology: Features and Enhancements
- Skill Level Beginner
- Supported Versions JavaFX 1.2
- Key Features Performance, Graphics, Language Enhancements
- Last Updated May 2009
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:
, Removed:
, Changed:
)
Animation
Packages affected: javafx.animation, javafx.animation.transition
Transition.interpolateis now namedinterpolator.
Old: public override var interpolate = Interpolator.LINEAR;New: public override var interpolator = Interpolator.LINEAR;The Transitionclass inherits from theTimelineclass.
The Transition.durationvariable inSequentialTransitionandParallelTransitionis inaccessible. However, the public-read protected variablescycleDurationandtotalDurationare now included in theTimeline.

public-read protected var cycleDuration: Duration
public-read protected var totalDuration: Duration
- The
timelinesvariable is no longer included inKeyFrame. Subtimelines are no longer supported. This functionality is now supported byParallelTransitionandSequentialTransition.
-
The
timelineDirtyvariable is no longer included in theTransitionclass. ThemarkDirty()function provides the same support as the oldtimelineDirtyvariable.timelineDirty, previously a protected variable of theTransitionclass, is now a local variable and can be modified through a protectedmarkDirty()function in theTransitionclass. This change enables a third-party library to extend the JavaFXTransitionbase class to implement additionalTransitionclasses. The existingTransitionclasses, such asTranslationTransition,RotateTranslation, andPathTransition, work as before.
Old: timelineDirty = true;New: markDirty()
Asynchronous Operations
Package affected: javafx.async
- The
AbstractAsyncOperationandRemoteTextDocumentclasses are no longer included in thejavafx.asyncpackage. Thejavafx.io.http.HttpRequestclass can be used instead of thejavafx.async.RemoteTextDocumentclass.
- The following classes are new to the
javafx.asyncpackage.
Effects
Package affected: javafx.scene.effect
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.Affineclass are now named as follows:
m00 --> mxx m01 --> mxy m02 --> tx m10 --> myx m11 --> myy m12 --> ty
However, the more common use case of using theTransform.affinemethod 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 namedjavafx.ext.swing.SwingUtils.toFXImage(image:java.awt.image.BufferedImage). The parameters and functionality are identical to the old method.
- The
javafx.scenepackage supports the following new classes:
- The
javafx.geometrypackage supports the following new classes:
- No events should be delivered when
Nodeis disabled.
- An application should not expect events on a disabled
Node. - Mouse and key event handlers should not be invoked when
Nodeis disabled. - A focused
Nodeshould lose focus when it becomes disabled.
- An application should not expect events on a disabled
- The
enabledvariable of Swing components in thejavafx.ext.swingpackage is no longer included. Thedisablevariable is still available and sufficient to handle the enabling and disabling of components.
- New layout variables are now included in
javafx.scene.Node,javafx.scene.CustomNode, andjavafx.scene.Group:
layoutInfolayoutBoundslayoutXlayoutY
- The preferred method to position a node for layout is
layoutXandlayoutYinstead of usingtranslateXandtranslateY. WhiletranslateXandtranslateYmost likely will work,layoutXandlayoutYwill have better performance. Also, if you do a legitimatetranslateXandtranslateY, the original value is lost if you did not uselayoutXandlayoutY.
- The default
layoutBoundsof a Node does not include clip, its effect, or any of its transforms.
- The implicit pivot of a Node when using the
scaleX,scaleY, orrotatevariables is the (untransformed) center of thelayoutBounds.
- The
boundsInScenevariable is no longer included in theNode,Group, andCustomNodeclasses. ThelocalToScene(boundsInLocal)function provides the same support as the oldboundsInScenevariable. TheboundsInScenevariable was expensive to compute, and thelocalToScene(boundsInLocal)function gives better performance because binding to thelocalToScenefunction is not allowed.
Old: node.boundsInSceneNew: node.localToScene(node.boundsInLocal) - The
javafx.scene.layoutpackage now includes the following classes.
Please see What's New in JavaFX 1.2: New Layouts and Effects for more information.
- A new Boolean
public-read protectedvariableneedsLayoutis inherited from thejavafx.scene.Parentclass in theClipView, Flow, Panel, Stack, Tile, HBox, andVBoxClasses.
- The
javafx.scene.layoutpackages,HBoxandVBox, now support positioning of the node within the allocated space by usingnodeVPosandnodeHPosrespectively. Under JavaFX SDK 1.1, all nodes were positioned at the top forHBox, and to the left forVBox.
- In the
javafx.scene.layout.Resizableclass, thepreferredHeightandpreferredWidthvariables are no longer included in theResizableclass. ThegetPreferredHeight()andgetPreferredWidth()functions provide the same support as the oldpreferredHeightandpreferredWeightvariables.preferredHeightandpreferredWidthare now local variables and can be accessed through the protectedgetPreferredHeight()andgetPreferredWidth()functions in theResizableclass.
Old: public-read protected preferredWidth: NumberNew: protected override bound function getPreferredWidth(): NumberOld: public-read protected preferredHeight: NumberNew: 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 withvisible: false;) was included in the bounds of theGroup. In JavaFX SDK 1.2, any invisible children do not contribute to the bounds of its parentGroup. If you want this behavior, set the child node to(visible:true; opacity:0;).
- The following classes are new to the
javafx.stage:
- The new
Screenclass causes thejavafx.screen.widthandjavafx.screen.heightproperties to become obsolete. Thejavafx.screen.widthandjavafx.screen.heightare no longer supported fromjavafx.FX.getProperty().
- The
Screenclass also includes adpiproperty for querying both the screen size and resolution (DPI).
- The
focusedvariable in thejavafx.stage.Stageclass is now namedcontainsFocus.
- 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.
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.

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 fromfxdContentis already a member of a Group createdFXDLoader. 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 thejavafx.fxd.Duplicatorclass 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
fromAWTColormethod is no longer included in thejavafx.scene.paint.Colorclass.
public fromAWTColor(c: java.awt.Color) : Color
- The
enabledvariable has been removed from thejavafx.ext.swing.SwingComponentsclass.
Keyboard and Mouse Events
Packages affected:
javafx.scene.control,
javafx.ext.swing,
javafx.scene.input
Nodeis not focusable by default and the key handler is not required forNodeto become focused with two exceptions:ControlandSwingComponentare focusable by default. The newfocusTraversablevariable is now included, and it is a Boolean. ThefocusTraversablevariable specifies whether thisNodeshould be a part of a focus traversal cycle.

-
A new
sourcevariable Node is now included in theMouseEventclass for event bubbling. Thesourcevariable is visually the topmost node in the node subtree under the mouse event. In the case where the node is a leaf node, thesourcevariable is the same as the node. In the case where the node is an instance of the Parent, thesourcevariable is visually the topmost node in the(@node)subtree under the mouse event.
- The
javafx.scene.inputpackage now includes the following classes.
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
mixinclass has been added. Inheritance rules now includemixinsand 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 ormixins. Amixincannot be instantiated directly.Mixinslook like regular classes, but have themixinmodifier on their declaration. For more information, see the JavaFX Language Tutorial.
- A comma is now required in explicit sequences:

[3, 77, 8]
But, like a semicolon, a comma is not required after }:
[Foo { x: 14 } Bar { sneeze: "cough" } ]
- The precedence of the
oroperator and theandoperator is changed. The JavaFXandoperator now has higher precedence than theoroperator.
a or b and c
is equivalent to:
a or (b and c)
- A
varin a block cannot have the same name as avarin a containing block. The following are now disallowed:
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");
}
}
on replace trigger is no longer allowed inside bind.
var x = bind for (i in [0..5]) {
var y = (i mod 2 == 0) on replace { //compile error
println("y changed");
}
y
}
Iterable are no longer allowed because they do not make sense and updates are not seen. Duration include the following: Duration.toMillis()returns Double instead of Number.Duration.INDEFINITEnow represents a time period of unknown length.Duration.toDate()is no longer supported.
firstininitintoinverselastonpostinitreplacesteptriggertweenwherewith
Media
Package affected: javafx.scene.media
- Real-time streaming protocol (RTSP) support is new. You can read more about RTSP on the RTSP wiki.

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.

-
Media has better support for video scrubbing.
Mobile
- Mobile now supports rectangular clipping.

- Cross-platform video (VP6 encoding) is supported, and FXM/VP6 is now included.

- The Mobile Emulator (Windows platform only) supports additional media files:

- 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.

-
Startup-time performance is an improvement over previous startup-time performance.

-
The compiler changes provide better runtime performance.

-
Please refer to the article on Performance Improvement Techniques for JavaFX Applications.
Persistence Storage
Package affected: javafx.io
Platform Support
- Support
is now provided for two additional OS platforms:

- 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.

- In the
javafx.fxdpackage, theFXDLoaderclass has additional variables and functions. TheFXDLoaderclass inherits from thejavafx.async.Taskclass to support the background loading of FXZ/FXD files.
- The
FXDNodeclass is added. TheUiStubclass is replaced with theFXDNodeclass. UI Stub files now extend from theFXDNodeclass.
- The
FXDNodeclass provides a choice of how graphics content is loaded: synchronous (which blocks other operations) or asynchronous (which runs in the background).
Scene {content: FXDNode {
url: "{__DIR__}mygraphics.fxz"
backgroundLoading: true
placeholder: Text { x: 10 y: 10 content: "Loading graphics ..."}
}
}
_root variable is no longer included in the FXDContent class. The getRoot() function
provides the same support as the old _root variable. UI Control Components
Package affected: javafx.scene.control
- The
javafx.scene.controlpackage now includes the following classes for creating UI controls.
-
Please refer to the article on JavaFX Scene UI Controls.
- The
Controlis now an abstract class and changed significantly.
- The
Behaviorvariable has been added to thejavafx.scene.control.Skinclass and removed from thefocused,hoverandpressedvariables.

- The
scenevariable has been renamed tonodein thejavafx.scene.control.Skinclass.
Old: public-init protected scene Node
New: public-read protected node Node
- The
Skinclass is now an abstract class and the newcontains()andintersects()functions are added. The existing function names are changed as follows.

- The
TextBoxclass has changed significantly and added new functionality.

| 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
|
UI Chart Components
Packages affected: javafx.scene.chart, javafx.scene.chart.data, javafx.scene.chart.part
- The new
javafx.scene.chartpackage now includes the following classes for chart components.
- The new
javafx.scene.chart.datapackage now includes the following classes for chart data components.
- The new
javafx.scene.chart.partpackage now includes the following classes for chart part components.
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 namedHttpRequest.start().
HttpRequest.cancel()is now namedHttpRequest.stop().
- These two public functions
are no longer included:

public function setHeader(name: String, value: String) public function getResponseHeaderNames(): String[]
-
The signature of these methods and fields changed from
IntegertoLong:
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
URLConverterclass is now included in thejavafx.io.httppackage.
- The new
javafx.data.feedpackage includes the following two classes:
- The new
javafx.data.feed.atompackage includes the following classes:
- A new
javafx.data.feed.rsspackage includes the following classes:
Miscellaneous
Packages affected:javafx.util, javafx.data- The new
javafx.datepackage has aDateTimeclass.
- The following classes
are new in the
javafx.utilpackage:
- The new
javafx.datapackage includes the following two classes:
- The new
javafx.reflectpackage includes the following two classes:
We welcome your participation in our community. Please keep your comments civil and on point. You may optionally provide your email address to be notified of repliesyour information is not used for any other purpose. By submitting a comment, you agree to these Terms of Use.
Inyoung Cho
Java Technology Consultant, Sun Microsystems