Java Reference
In-Depth Information
content: bind text
font: Font{ name: "Times-Roman Bold" ,
size:25}
stroke: Color.NAVY
}
]
}
}
}
This custom node is comprised of a group containing a rectangle that fills the
entire background with a linear gradient paint, a circle, and a text. The create()
function returns the group, which is a node. This is the most common way to cre-
ate a custom node, but this is not the only way. The only requirement is that the
returned object extend javafx.scene.Node .
javafx.scene.Group
The Group ( javafx.scene.Group ) node contains a sequence of child nodes that
are displayed in the order reflected in the sequence. It merely displays the nodes
as they are defined and will take on the geometric bounds that encapsulate all its
children. It does not do any layout for the children and each child node must
position itself. Its main purpose is to group together a set of nodes and allow
those nodes to be manipulated as a group. For example, you can apply trans-
forms to the group, change its visibility or opacity, and so on.
The order of the nodes in the Group's content sequence dictates which nodes are
drawn first and which are drawn last. If there is overlap on the display, nodes at
the beginning of the content sequence will be underneath nodes later in the
sequence. Actually, the Node 's method toFront() moves the affected node to
the end of the containing Group's content sequence. Likewise, toBack() merely
moves the affected node to the beginning. Of course, you can always change the
order of the nodes assigned to content to achieve the desired layering.
Layout
JavaFX has two layout controls: javafx.scene.layout.HBox and javafx
.scene.layout.VBox . HBox lays out its nodes horizontally, whereas VBox does it
vertically.
Listing 5.14 illustrates an example using the horizontal box ( HBox ) layout.
 
 
 
Search WWH ::




Custom Search