Reputation: 43
How add text in pane border in JavaFX like this:
Upvotes: 0
Views: 1562
Reputation: 13859
This is similar to a node they have in c#
. I don't know if JavaFX
has this type of node. In SceneBuilder
I added a border around a Pane
and a Label
on top of the border. I then set the root AnchorPane
's background to white and the Label
's background to white. I did not try this with Group
but I am guessing it might be a good idea.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" style="-fx-background-color: White;" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Pane fx:id="pane" layoutX="200.0" layoutY="100.0" prefHeight="200.0" prefWidth="200.0" style="-fx-border-color: BLACK;" />
<Label layoutX="218.0" layoutY="92.0" style="-fx-background-color: WHITE;" text="Label" />
</children>
</AnchorPane>
Upvotes: 2