How do I add a text at the center of a rectangle? I've been searching and have not found a way to do this.
See the class below:
public class Agent extends Rectangle{
public Agent() {
setWidth(60);
setHeight(60);
setArcWidth(60);
setArcHeight(60);
setFill(Color.BLUEVIOLET.deriveColor(0, 1.2, 1, 0.6));
setStroke(Color.BLUEVIOLET);
}
}
Thanks!
Add the Text
element and the Agent
(Rectangle
) element in a StackPane
.
Text text = new Text("...");
...
StackPane stack = new StackPane();
stack.getChildren().addAll(agent, text);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With