Generated Object
javafx.scene.Node
Value
The custom node object
Attributes
This node takes the attributes of the javafx.scene.Node class. see javafx.scene.Node
In addition, if a value is not present, then the following attribute is required:
node: the custom node object
Content
This node may take general javafx node content like effects, transforms and inputs
Usage
Creates a Custom Node.
Examples
| Code Block |
|---|
import groovyx.javafx.SceneGraphBuilder
import groovyx.javafx.GroovyFX
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.layout.Region;
class MyCustomNode extends Region {
public MyCustomNode() {
getChildren().add(create());
}
protected javafx.scene.Node create() {
return new Rectangle(width: 10, height: 10, fill: Color.BLUE);
}
}
GroovyFX.start({
def sg = new SceneGraphBuilder();
sg.stage(
title: "Custom Node example",
x: 100, y: 100, width: 200, height:200,
visible: true,
style: "decorated",
onHidden: { println "Close"}
) {
scene(fill: hsb(128, 0.5, 0.5, 0.5)) {
node(new MyCustomNode(), layoutX: 10, layoutY: 10) {
scale(x: 5, y: 5)
onChange(property: "hover", changed: {observable, oldValue, newValue -> println "hover: " + oldValue + " ==> " + newValue})
}
}
}
});
|