JavaFX 1.3 Migration Guide
- Skill Level All
- Supported Versions JavaFX 1.3
- Key Features JavaFX 1.2 to 1.3
Migration - Last Updated May 2010
The JavaFX 1.3 SDK is an important update to the JavaFX 1.2 SDK. Most applications will need little or no modification to compile and run on JavaFX 1.3, but there are a few incompatible changes that application developers may need to be aware of. For a higher-level description of new features and enhancements introduced in this release, see What's New in JavaFX 1.3. For a tutorial on using the JavaFX 1.3 UI controls, see Using JavaFX UI Controls.
Migrating Existing Applications to JavaFX 1.3
This section describes the issues that an application developer may face when migrating from JavaFX 1.2 to JavaFX 1.3. It consists of compiler changes, API changes, semantic changes, and additional migration tips. Immediately following each description is a paragraph beginning with the text "Source Change Needed." These paragraphs provide specific suggestions for migrating an application's source code to JavaFX 1.3.
Compiler Changes
The following compiler changes may cause application developers to modify their source code. For a complete list of compiler changes, see the Compiler and Language Changes (Full Details).
JavaFX 1.3 is not binary-compatible with JavaFX 1.2
Class files produced by the JavaFX 1.2 SDK will not run directly on JavaFX 1.3. All JavaFX Script source files need to be recompiled with the JavaFX 1.3 SDK.
Source Change Needed: None
Some forward references now get errors instead of warnings
In JavaFX 1.2, most forward references caused compiler warnings. However, the value used for such a forward reference was the default value of the type of the referenced variable, not that variable's initial value. Using such a forward reference could lead to unpredictable behavior, so the JavaFX 1.3 compiler generates an error instead of a warning.
For example:
var x = y;
var y = 10;
println("{x}");
will cause the following error to be generated:
Sample.fx:1: Illegal forward reference: variable y is not initialized.
var x = y;
^
1 error
Source Change Needed: Eliminate any forward references that cause errors, either by reordering the variable declarations, or by separating the variable declarations from their assignments.
Side effects are no longer allowed in bind expressions
In JavaFX 1.2, it was possible to bind to an expression with a side effect, such as assigning a value to an instance variable. In JavaFX 1.3, bind expressions are evaluated lazily, so there is no guarantee how often or when a bind expression will be evaluated. Allowing side effects would lead to unpredictable behavior, so they are no longer allowed.
Here is an example of a bind which has a side effect:
var yy: Integer;
var zz = 10;
var xx = bind { yy = zz }; // yy = will get an error in JavaFX 1.3
println("xx={xx}, yy={yy}");
zz = 89;
println("yy={yy}");
The side effect of the bind is that yy is set to the value of zz. In JavaFX 1.2, this code compiles and executes without problem. In JavaFX 1.3, the compiler generates an error message:
Sample.fx:3: Not allowed in bind context =
var xx = bind { yy = zz };
^
1 error
Source Change Needed: Place any necessary side effects in an "on replace" trigger rather than in the bind expression itself.
Binds can be lazy if there is no associated on replace clause
In JavaFX 1.2.3, binds are "eager." When a variable in the bind expression changes value, the bind expression is computed and the resulting value is stored into the binder variable. Now that side effects are no longer allowed in binds, this change will not be noticeable to an application.
Source Change Needed: None, other than avoiding side effects as previously described.
API Changes
Most enhancements to the JavaFX API are simple additions of new classes, or new variables and functions in existing classes. A few incompatible API changes were made in JavaFX 1.3 that may require changes to an application's source code, either because the API call itself has been altered in some way, or because the semantics have changed in an incompatible manner. The following items describe the incompatible changes, plus any source code changes that may be needed to react to them.
Modified or Removed Variables and Functions
- The following variables each had an access modifier of
publicin JavaFX 1.2.3, meaning that an application could write to any of these variables at any time. They were not intended to be writable variables, however, and modifying them had no meaningful effect. The access modifiers have now been changed to reflect the correct usage of these variables:
public-read: AppletStageExtension.appletDragSupported
public-read: MediaError.cause, MediaError.message
public-read: MediaPlayer.currentCount
public-init: Media.source
Source Change Needed: Few, if any, applications should be affected by this change. The solution is to remove the code that was previously writing to these variables. In the case of
Media.source, you should now initialize thesourcevariable when creating aMediaobject, for example:Media { source: "urlstring" } - Type change for
Slider.minorTickCount
In previous releases, the
minorTickCountvariable of theSliderclass was declared asNumber. Since it does not make sense to have, for example, 2.5 minor ticks between two major ticks, this variable's type has now been changed toInteger.
Source Change Needed: Most applications will need no changes. If you use theminorTickCountvariable in arithmetic expressions, castingminorTickCounttoNumbermay be required if non-integer arithmetic is needed. Conversely, you may now see a "possible loss of precision" warning when assigning a numerical expression to theminorTickCountvariable. This warning may be safely ignored, or the resulting expression may be cast toIntegerprior to assignment to avoid the warning. -
ContainerandControlnow extendParentdirectly
The
ContainerandControlclasses now each extendParentinstead ofGroupandCustomNode, respectively. This provides more freedom in establishing the relationship betweencontentandchildren, and puts all three base parent types (Group,Container,CustomNode) on the same level, cleaning up the layout API and enabling each to evolve independently without affecting the others.
Source Change Needed: None needed forContainer, unless you were casting aContainertoGroup, or setting itsgroupBlendvariable. Application developers should remove such usage from their programs. None needed forControl, unless you were trying to subclass and create a custom control by overriding thecreate()function ofCustomNode. Such usage would not have worked anyway and should be removed. - Removal of
doLayout()function fromGroup
In JavaFX 1.2,
ContainerextendedGroupand both classes exposed adoLayout()callback function to perform layout of content during the layout pass. In JavaFX 1.3,Containernow extendsParentdirectly, becoming the definitive layout base class, providing thedoLayout()function to be overridden by subclasses.Groupno longer hasdoLayout().
Source Change Needed: Existing code which subclassesGroupand overridesdoLayout()should now extendContainerinstead. Chart,Legend, andAxisnow extendParentdirectly
TheChart,Legend, andAxisclasses now each extendParentinstead ofCustomNode. This provides more freedom in establishing the relationship betweencontentandchildren. Additionally, the type ofprotected var Chart.chartContenthas changed fromContainertoNode, and the type ofprotected var XYChart.plothas changed fromPaneltoContainer.
Source Change Needed: None, unless an application creates a custom subclass ofChart,Legend, orAxis, which isn't a common use case (and likely didn't work in JavaFX 1.2). If such a subclass does exist, and currently overrides thecreate()function ofCustomNode, you will need to remove this usage.
-
ToggleGroupnow usesTogglemixin.
Previously,
ToggleGroupworked exclusively withToggleButtonobjects. In this release,ToggleGroupalso works withRadioMenuItemobjects. ATogglemixin class has therefore been created.
With this change, the following line:
public-read package var buttons:ToggleButton[];
becomes:
public-read package var toggles:Toggle[];
and this line:
public var selectedButton:ToggleButton;
becomes:
public var selected:Toggle;
Source Change Needed: Application developers can simply change the usage of the variable names and types to match the new API. - Removal of the following protected functions.
protected function Flow.computeDimension()
protected function Container.initSize()
Source Change Needed: These functions are no longer needed. Application developers may safely remove these functions from any class that extends
FloworContainer. - Removal of boolean variable
Text.overline
While
underlineandstrikethroughare both commonly used in typography, there is little precedent foroverline. Removal of this feature helps improve performance, and simplifies text-handling code. Unlikestrikethroughandunderlinewhich are sometimes supported in the font,overlineis not. This variable has therefore been removed from theTextclass.
Source Change Needed: Remove any usage of this variable. - Promotion of
managedvariable fromLayoutInfoBasetoNode
The
managedvariable has been moved fromLayoutInfoBasetoNode.
Source Change Needed: Application developers that wish to make a node unmanaged should setmanaged=falsedirectly onNodeinstead of in aLayoutInfoused by thatNode. - Variable name changes in
javafx.scene.chart.Chart
The previous release contained typos in some
Chartvariable names. The following variables have therefore been renamed:
chartBackgoundFillis nowchartBackgroundFill
chartBackgoundStrokeis nowchartBackgroundStroke
chartBackgoundStrokeWidthis nowchartBackgroundStrokeWidth.
Source Change Needed: Change the spelling of the names as shown.
Semantic Changes
- Preferred size for
FlowandTile
The
FlowandTileclasses previously contained buggy algorithms for computing their preferred sizes. TheTileclass now computes its preferred width and height based on therowsvariable (for horizontal) andcolumnsvariable (for vertical). The rows and columns no longer reflect the actual number of displayed rows and columns that could change if aTileobject is resized to something other than its preferred size. In addition, theFlowclass now has awrapLengthvariable that controls the preferred width (horizontal) or height (vertical).
Source Change Needed: Few, if any, applications should need any modification.
- Containers and Controls no longer initialize their sizes in
postinit
In previous releases, the
ContainerandControlclasses all initialized theirwidthandheightvariables to their preferred sizes. This is no longer the case in JavaFX 1.3, since CSS styling now plays a vital role in what the preferred size of aControlshould be, and CSS is not initialized until theControlis added to aSceneand the first pulse occurs.
Source Change Needed: Few, if any applications should need any modification. - Groups now auto-size
Resizablenodes
In previous releases, controls that were not placed in a layout container were not automatically resized. In JavaFX 1.3, all
Parentclasses (Group,Container, andCustomNode) will automatically resize any managedResizablechildren to their preferred size. Controls will now be properly resized regardless of where they are placed in the scene graph. With this change, it becomes imperative that allResizablenodes return appropriate values fromgetPrefWidth()andgetPrefHeight(), since theParentnode will use the values returned by those functions to determine the size to give the resizable node during layout. IfgetPrefWidth()orgetPrefHeight()erroneously return0, then the node will not be visible, because it will be resized to0 x 0.
Source Change Needed: Most application developers will want the new default behavior in JavaFX 1.3. If automatic resizing is not desired for a particularGroupnode, you may setGroup.autoSizeChildren = falseto restore the JavaFX 1.2.3 behavior. - Containers and Controls now have default grow, shrink, and
fill behaviors
In JavaFX 1.2,
Resizablenodes could only express their minimum, preferred, and maximum size preferences. IfContainers were allocated more or less space than their preferred sizes, they used their own policy for determining how to distribute that differential space.HBox,VBox, andFlowalways resized children to their preferred sizes, regardless of how much space existed.StackandTilewould automatically expand children beyond their preferred sizes to fill their layout space. In JavaFX 1.3, grow, shrink, and fill preferences have been added toResizableso that theContainerclasses can make resizing decisions based on their type of content rather than using its own policy which may not make sense for the content.
MostControls (Button,Label, etc.) return grow and shrink preferences ofNEVER, and a fill preference offalse. This means that when placed inside containers that have extra space, these controls will not be resized beyond their preferred sizes to take up that additional space. For example, if aButtonwere placed inside aStackin JavaFX 1.2, it would be resized to fill theStack(which might be large, depending on its content); however, in JavaFX 1.3, theStackwill honor theButton's no-grow preference and keep it to its preferred size, regardless of how big theStackis, which is usually the desired outcome for aButton.
SomeControls (ListView,ScrollView) and allContainers return grow and shrink preferences ofSOMETIMES, which means that when placed inside Containers with extra space, they will be resized beyond their preferred sizes to take their share of extra space (provided no other children in the container have a grow preference ofALWAYS, which has a higher priority). This is a change from JavaFX 1.2, where containers placed inside other containers would grow only if the parent container were aStackorTile; otherwise, they were kept to their preferred size, even though their parent had more room.
Source Change Needed: Most application developers will want the new default behavior. Applications that depend on the JavaFX 1.2 behavior may now see that containers (HBox,VBox, etc.) are suddenly growing in size as the overall scene is resized, when they previously were kept to their preferred size. If the old behavior is desired, an you can useLayoutInfoto override the grow/shrink/fill preferences.For example:
def NO_GROW = LayoutInfo { hgrow: Priority.NEVER vgrow: Priority.NEVER };
VBox {
// ensure VBox tracks size of scene when user resizes stage
width: bind scene.width
height: bind scene.height
content: [
HBox { layoutInfo: NO_GROW ... }
ListView { layoutInfo: NO_GROW ... }
...
]
}
- Support added for vertical filling in
HBoxand horizontal filling inVBox
With the addition of the growing/filling layout behavior in JavaFX 1.3, it became necessary to enable an
HBoxto set the height of each child's layout area to theHBox's actual height (rather than the height of the tallest child) and aVBoxto set the width of each child's layout area to theVBox's actual width (rather than the width of the widest child). To control this behavior,HBoxhas a newfillHeight:Booleanvariable andVBoxhas a newfillWidth:Booleanvariable, both of which default totrue, since this turns out to be the more commonly desired layout behavior. In addition, the variablevfill(of classHBox) has been renamedfillHeight, and the variablehfill(of classVBox) has been renamedfillWidth.
Source Change Needed: If an application depends on the older behavior where the layout areas are limited to the height of the tallest child (HBox) or width of the widest child (VBox), even when there is more space in the container, then it can set the variable to false:
HBox { fillHeight: false }
VBox { fillWidth: false } - Focus traversal mechanism change
In previous releases, the behavior of the focus traversal mechanism was to "steal" certain keystrokes, such as
TABandshift-TAB. PressingTABorshift-TABwould cause focus traversal to occur instead of a key event being delivered to the focused node. That mechanism has been removed: all keystrokes are now always delivered to the focused node. Nodes that process key events and subsequently move the focus should callNode.requestFocus()in response to the appropriate event.
Source Change Needed: Few, if any, applications should require focus traversal on their own scene graph nodes. Applications that do need this feature must explicitly callNode.requestFocus()when the appropriate key is pressed.
- Animation: Changed semantics of
KeyValueevaluation
In previous releases, the value that
Timelineused forkeyValuewas updated dynamically. That is, on every pulse it would query for the current value ofkeyValueon everyinterpolate()call. This allowedkeyValueto change at any time, from anywhere. However, this behavior came at the expense of performance, and was wasteful in the majority of cases.In this release, all
KeyValues are evaluated once before theTimelineobject plays for the first time.KeyValues retain this value until an explicit request for reevaluation.A new function,
Timeline.evaluateKeyValues()has also been added. When called, allKeyValues in the Timeline are reevaluated.Source Change Needed: Applications that need their KeyValues to be evaluated between successive runs of a Timeline will need to add a call to
Timeline.evaluateKeyValues()before callingplayFromStart()orplay().
Additional Migration Tips
CSS
In JavaFX 1.2, the CSS properties used the same names as those
in the WC3 CSS specification, even though they did not fully implement
the specification. W3C provides a
convention for vendor-specific
extensions, which JavaFX now uses. All CSS properties in JavaFX are now
prefixed with "-fx-",
for example, "-fx-font-size", which specifies
the size of the font to use in a CSS declaration.
Setting the Size of Nodes
To set the size of a node in JavaFX 1.3, you can set the node's layoutInfo
variable:
JavaFX 1.2
var searchBox = VBox {
content: [
Label {
height: 20
...
}
...
]
}
JavaFX 1.3
var searchBox = VBox {
content: [
Label {
layoutInfo: LayoutInfo { height: 20 }
...
}
...
]
}
Alternatively, you can make the node unmanaged by setting managed
to false.
Media Files
Media files can no longer be loaded directly from .jar
files. See JavaFX
FAQ Section 5.3 for more information.
Establishment of control width and height
In previous releases, a control's width and height was established
immediately when the control was created. In JavaFX 1.3, the width and height are established
asynchronously, when the first layout pass is done. If code relied on a
control's width and height to be established early (for example, using those values to compute layoutX during initialization),
this code will no longer work in JavaFX 1.3. Remedies are to use bind,
or to use width and height during the layout pass, as in the onLayout
function of a Panel.
Additional Features in JavaFX 1.3
This section describes the new JavaFX 1.3 features that an application developer may wish to use. It contains additional information about the compiler and language changes, plus descriptions of the API enhancements introduced in this release.
Compiler and Language Changes (Full Details)
JavaFX 1.3 is not binary-compatible with JavaFX 1.2
Class files produced by the JavaFX 1.2 SDK will not run directly on JavaFX 1.3. All JavaFX Script source files need to be recompiled with the JavaFX 1.3 SDK.
Some forward references now get errors instead of warnings
In JavaFX 1.2.3, most forward references caused compiler warnings. However, the value used for such a forward reference was the default value of the type of the referenced variable, not that variable's initial value. Using such a forward reference could lead to unpredictable behavior, so the JavaFX 1.3 compiler generates an error instead of a warning.
For example, in JavaFX 1.2 this code:
var x = y;
var y = 10;
println("{x}");
will get a warning on line 1, and will print 0, which is not what was intended.
In JavaFX 1.3, an error will be generated:
Sample.fx:1: Illegal forward reference: variable y is not initialized.
var x = y;
^
1 error
You can avoid this error while preserving the same semantics as in JavaFX 1.2.3 by removing the initializer and adding the correct type, for example:
var x:Integer;
var y = 10;
println("{x}");
This code will cause x to be initialized with the
default value for type Integer, which is the
same behavior as in JavaFX 1.2.3. However, if you want to initialize x with the initial value
of y, then the code should be reordered so
that y is declared first:
var y = 10; // reorder the variables
var x = y;
println("{x}");
There are various other contexts in which a forward reference will not cause an error message because there are some circumstances in which the program will behave as expected. The following option will cause the compiler to generate warning messages on these forward references:
-XDfwdRefOpt="objlit|bind|interpolate|keyframe|lambda|assign|onreplace|oninvalidate"
Any subset of the list of keywords can be used, for example,
-XDfwdRefOpt="bind|onreplace". This is an unsupported option which is subject to change.
Side effects are no longer allowed in bind expressions
In JavaFX 1.2, an application could bind to an expression with a side effect, such as assigning a value to an instance variable. In JavaFX 1.3, bind expressions are evaluated lazily, so there is no guarantee how often or when a bind expression will be evaluated. Allowing side effects would lead to unpredictable behavior, so they are no longer allowed.
Here is an example of a bind which has a side effect:
var yy: Integer;
var zz = 10;
var xx = bind { yy = zz }; // yy = will get an error in JavaFX 1.3
println("xx={xx}, yy={yy}");
zz = 89;
println("yy={yy}");
The side effect of the bind is that yy is set
to the value of zz. In JavaFX 1.2.3, this code compiles and executes
without problems. In JavaFX 1.3, the compiler
generates an error message:
Sample.fx:3: Not allowed in bind context =
var xx = bind { yy = zz };
^
1 error
Binds can be lazy if there is no associated on replace clause
In JavaFX 1.2.3, binds are "eager." When a variable in the bind expression changes value, the bind expression is computed and the resulting value is stored into the binder variable.
For example:
var xx = bind fred(zz);
when zz changes value, fred(zz)
is called and the returned value is stored into xx.
In JavaFX 1.3, binds can be lazy. This means that the compiler is free
to optimize the generated code to delay the computing of the new value
of the bind expression, and the storing of that value into the binder
variable, until the binder variable is actually referenced. In the previous
example, if zz is modified from 1 to 1000 in
a for loop before xx is referenced, the result in JavaFX
1.2.3 is that fred(zz) is called 1000 times, while in
JavaFX 1.3, fred need not be called at all
until xx is referenced. Then a single call - fred(1000)
can be performed and the result stored into xx.
Allowing for lazy binding makes the computing of a bind expression somewhat non deterministic: it doesn't have to happen at a particular point in the execution of the program, and doesn't have to happen at all in some cases. This is why side effects are no longer allowed in bind expressions - you can't count on when, or even if, the side effects will actually occur.
An on replace clause on a declaration with a
bind acts like an implicit reference to the binder variable. This
forces the bind, and other binds upon which it depends, to be eager.
For example:
var x1: Number;
var x2 = bind x1 * 3;
var x3 = bind x2 on replace { foo() };
Both binds will be eager. When x1 changes,
the on replace clause causes an implicit reference to x3,
so its value is needed and its bind expression (x2)
must be evaluated. To obtain the new value for x2,
its bind expression (x1 * 3) must be
evaluated.
Even though both binds in the example will be eager,
side effects are still not allowed in their bind expressions. If a
side effect of a bind expression is desired, it can sometimes be
accomplished in an on replace clause, for
example:
var yy: Number;
var xx = bind fred(zz) on replace {yy = zz};
New on invalidate clause and invalidate statement
The on invalidate clause and invalidate statement are new features
in JavaFX 1.3. They can be used together with
lazy binds to improve performance. An on invalidate
clause is similar to an on replace clause in that it includes a block
of code, and it can be added to a variable definition. However, an on
invalidate clause does not force a bind to be eager as
does an on replace clause. The semantics of this
var y ... on invalidate {code block}
are that the code block is executed when y
might have become invalid, (for example, when a new value has been
designated for y), which means that the next
reference to y must not get the old value of y.
More specifically:
- If
yis referenced two times and the second yields a different value than the first reference toy, then theon invalidatecode block will have been executed at least once between the two references.
- If
yis explicitly invalidated with the new invalidate statement. For example:
invalidate y;
then the on invalidate code block will be
executed at least once between the execution of the invalidate
statement and the execution of the next reference to y.
New isReadOnly(xxx) synthetic method
isReadOnly is a synthetic method that takes a
single
argument, which must be a script or instance variable reference that is
defined with a var (as opposed to an
expression, or a variable defined with a def).
isReadOnly(xx) returns true
if xx cannot be modified, otherwise it returns false.
Currently, the only vars which are read-only are those defined with a
bind without inverse.
For example:
var x;
var y = bind x;
var z = bind x with inverse;
println("is x bound ? {isReadOnly(x)}");
println("is y bound ? {isReadOnly(y)}");
println("is z bound ? {isReadOnly(z)}");
This code will print:
is x bound ? false
is y bound ? true
is z bound ? false
isReadOnly can be used in a member function to
detect that a subclass has added a bind to an instance variable, which
means that the variable must not be modified.
API Enhancements
A compatible API change is an addition to the API in the form of a new
public or protected class, function, var, or def.
- New grow, shrink, and fill functions for
Resizable
The functions
getHGrow,getHShrink,getVGrow,getVShrink,getHFill, andgetVFillhave been added toResizableso that nodes can express their preferred resizing behaviors. - New
KeyCodevariables to support TV remote controls
The KeyCode class now contains the following additional codes to support TV remote controls:
VK_BACKVK_CANCELVK_CHANNEL_DOWNVK_CHANNEL_UPVK_COLORED_KEY_0VK_COLORED_KEY_1VK_COLORED_KEY_2VK_COLORED_KEY_3VK_EJECT_TOGGLEVK_FAST_FWDVK_INFOVK_MUTEVK_PAUSEVK_PLAYVK_POWERVK_RECORDVK_REWINDVK_STOPVK_TRACK_NEXTVK_TRACK_PREVVK_VOLUME_DOWNVK_VOLUME_UP
- Allow
CustomNodeto have multiple children to eliminate needing an extraGroup.
Previously,
CustomNodereturned a single node via itscreate()function. This meant that virtually everyCustomNodeobject would create aGroupto hold its content. ForCustomNodes defined with a small number of shapes, the memory overhead of thisGroupwas noticeable.This change addresses this issue as follows:
protected var children:Node[];has been added toParent.
- The
Groupclass now contains the followingcontentimplementation:
public var content:Node[];
override var children = bind content with inverse; CustomNodeimplementations can now either use the existingcreate()mechanism or add nodes directly to thechildrensequence.
- Multi line (single-style) support added to
TextBox
The
TextBoxclass now supports multi line (single-style) text. For a tutorial about using this control, see Using JavaFX UI Controls. TextBoxhas been refactored
TextBoxhas been refactored to supportPasswordBox,SearchBox, and other text input controls. The purpose of this change is to reuse the common API/implementation between them.TextBoxaction()andcommit()functions have been moved up toTextInputControl
In this release,
actionandcommitare defined inTextInputControland then inherited intoTextBox.- New control key function support
TextBoxnow supports the following control key functions:CTRL + HOME
CTRL + END
CTRL + RIGHT/LEFT ARROW
CTRL + SHIFT + RIGHT/LEFT ARROW
CTRL + SHIFT + HOME/END - New support for custom cursors
The new
javafx.scene.ImageCursorclass provides a custom image representation of the mouse cursor. On platforms that don't support custom cursors,Cursor.DEFAULTwill be used in place of the specifiedImageCursor. - New layout support for baseline alignment
Vertical baseline alignment support has been integrated into all
Containers and a subset ofControls:Label,CheckBox,Button,Hyperlink,RadioButton,ToggleButton,Slider, andTextBox. A new mixin class,TextOffsets, has been added that defines offsets needed to align nodes based on their text content. Controls can now be aligned in this manner by simply setting theirnodeVPostoVPos.BASELINE. SinceContainerimplementsTextOffsets, all concreteContainerclasses have abaselineOffsetvariable which defaults to the baseline location of the first node in theContainerobject's managed content. To assistContainerimplementations in supporting baseline alignment for layout, various script-level utility functions have been added toContainer:public bound function getNodeBaselineOffset(node:Node):Numberpublic function getMaxBaselineOffset(content:Node[]):Numberpublic function positionNode(node:Node, areaX:Number, areaY:Number, areaWidth:Number, areaHeight:Number, areaBaselineOffset:Number, hpos:HPos, vpos:VPos, snapToPixel:Boolean):Void
- New layout support for snap-to-pixel
In previous releases, the layout functions did not round to pixel boundaries, which could cause nodes to appear fuzzy. This change adds a
snapToPixelvariable toContainer, plus versions of the layout utility functions that accept it as a parameter. This change also modifies all the concrete containers to properly call these functions. - New
PasswordBoxcontrol
A new
PasswordBoxcontrol has been added in this release. For a tutorial about this control, see Using JavaFX UI Controls. - New
marginsandpaddingvariables
All containers now honor both node margins and container padding.
public var margins:Insetshas been added toLayoutInfo, andpublic var padding:Insetshas been added to all other container classes. - Layout Growing, Shrinking, & Filling
In previous releases, the policy of how to resize a
Resizablenode within a given container's space was left solely up to the container. Additionally, when a container was resized larger (or smaller) than its preferred size, there was no way to specify how that increased (or decreased) space should be distributed across nodes. This change addresses the need to control more precisely howResizables are resized given dynamically changing available space. This change enhances theLayoutInfoconstraints to enable these details to be specified on a per-node basis within containers. - New way to specify text bounds type
This change adds a new
boundsTypevariable to theTextnode that affects whether the bounds are calculated as logical or visual bounds. (Logical bounds are better for component layout and performance. Visual bounds are better for precise positioning of specific text and will provide tighter bounds around that specific text.)TextBoundsType.LOGICALis the default. - Support for bounds-based picking of
Textnode
The new
Text.pickOnBoundsvariable defines how the picking computation is done for a node when triggered by aMouseEventor acontainsfunction call. IfpickOnBoundsis true, then picking is computed by intersecting with the bounds of the node, else picking is computed by intersecting with the geometric shape of the node. The default value forpickOnBoundsfor text nodes istrue, meaning that you can pick anywhere in the string, including gaps between letters or holes within letters (for example, in the middle of an "O"). - Additional bitmap cache hinting to allow smoother animation
A new
Node.cacheHintvariable was added to control caching, with values of:CacheHint.DEFAULT,CacheHint.SCALE,CacheHint.ROTATE, andCacheHint.SCALE_AND_ROTATE. -
DropShadowandInnerShadownow haveinputvariable
The
DropShadowandInnerShadowclasses now have publicinputvariables. - New API to Query "common conditional" features
This change adds an API that allows developers to query which common conditional features are present in the system. Common conditional features may not be available on all platforms. An application that wants to know whether a particular feature is available may query this using the
Platform.isSupported()function. Using a conditional feature on a platform that does not support it will not cause an exception. In general, the conditional feature will just be ignored. - New
SeparatorControl
A new
Separatorcontrol has been added in this release. For a tutorial on using this control, see Using JavaFX UI Controls. - New API for disabling auto-sizing on
Groupobjects
A new
BooleanvariableautoSizeChildrenhas been added toGroup. This variable makes it possible to disable any automatic autosizing behavior, eliminating theGroup's active participation in layout. Doing so means that the application is taking responsibility to ensure that the children of thatGroupare being laid out another way, either by theGroup's parent'sdoLayout()function or by explicit sizing and positioning. - New
ScrollViewcontrol
A new
ScrollViewcontrol has been added in this release. For a tutorial on using this control, see Using JavaFX UI Controls. - New
ChoiceBoxControl
A
ChoiceBoxcontrol has been added in this release. For a tutorial on using this control, see Using JavaFX UI Controls. - New
TooltipControl
A
Tooltipcontrol has been added in this release. For a tutorial on using this control, see Using JavaFX UI Controls. - Add asynchronous
parse()toPullParser
In this release, a new public class
javafx.data.pull.ParserTaskhas been added.