javafx.scene.Parent
The custom container object
This node takes the attributes of the javafx.scene.Parent class. see javafx.scene.Parent
In addition, if a value is not present, then the following attribute is required:
container: the custom parent object
This node may take general javafx node content like effects, transforms and inputs. Also it make take JavaFX nodes that are added to the custom container.
Creates a Custom Container.
import groovyx.javafx.SceneGraphBuilder
import groovyx.javafx.GroovyFX
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.layout.Region;
import javafx.geometry.HPos;
import javafx.geometry.VPos;
class SimpleContainer extends Region {
public SimpleContainer() {
}
@Override
protected void layoutChildren() {
List<Node> managed = getManagedChildren();
def width = getWidth();
def height = getHeight();
def partWidth = width/managed.size();
def x = 0
for(n in managed) {
layoutInArea(n, x, 0, partWidth, height, 0,
HPos.CENTER, VPos.CENTER);
x += partWidth;
}
}
}
GroovyFX.start({
def sg = new SceneGraphBuilder();
sg.stage(
title: "Custom Container example",
x: 100, y: 100, width: 200, height:200,
visible: true,
) {
scene(fill: hsb(128, 0.5, 0.5, 0.5)) {
container(new SimpleContainer()) {
button(text: "one")
button(text: "two")
button(text: "three")
}
}
}
});
|