Java Reference
In-Depth Information
To implement this, Title first extends CustomNode then implements the create()
function. In the create function, it creates a rectangle that fills the background, a
circle, and a text object to display “JavaFX is Cool”. This is shown in Figure 5.7
and Listing 5.13.
Figure 5.7
Title Object Display
Listing 5.13
“JavaFX is Cool” - CustomNode
public class Title extends CustomNode {
public var text:String = "JavaFX is Cool";
public var width:Number = 200;
public var height: Number = 100;
override function create(): Node {
Group {
content: [
Rectangle {
width: bind width
height: bind height
fill: LinearGradient {
startX: 0 startY: 0
endX: 0 endY: 1
stops: [
Stop { offset: 0.0
color: Color.DODGERBLUE },
Stop { offset: 1.0
color: Color.WHITE }
]
}
},
Circle {
centerX: bind width / 4 * 3;
centerY: bind height / 2
radius: bind height / 3
fill: Color.CORAL
},
Text {
translateX: 5
translateY: bind height / 2 + 10
continues
Search WWH ::




Custom Search