Java Reference
In-Depth Information
This JavaFX code then gets the JSON string from the TextMessage object and
parses it using a javafx.data.pull.PullParser . For detailed information on
using the PullParser class, consult Chapter 10, Create RESTful Applications.
Listing 12.4 shows the simple implementation to process the clock JSON message.
Listing 12.4
JSON Clock Message
public var millis: Number;
var parser = PullParser {
documentType: PullParser.JSON
onEvent: function(e: Event) : Void {
if(e.type == PullParser.END_VALUE and
e.name == "clock") {
var milliStr = e.text;
millis = java.lang.Long.valueOf(milliStr);
}
}
};
The instance variable, millis , needs to be a Number rather than an Integer,
because the actual value of the System time is larger than an Integer can hold.
Another way to declare millis is with a Long .
Node Effects—Fader and Magnifier
A common effect is for a node to fade in to out as a transition between views. A
transition effect allows a smoother change from one view to another. Another
common effect is to magnify a node when the mouse hovers over it. The follow-
ing code recipes show a way to implement these effects using reusable classes.
Fader
The Fader class supports the visual fade in or out of a node. If fade in is desired,
when a node is shown, it will transition from invisible to visible over a period of
time. If fade out is chosen, it will change from visible to invisible. There is also a
setting for scaling while these transitions occur. Using scaling, the node can
grow from small to normal size as it transitions to visible. On the reverse side,
while fading out, the node can shrink from its normal size.
 
 
 
Search WWH ::




Custom Search