How add text in pane border in JavaFX like this:
Asked
Active
Viewed 1,382 times
0
-
Your question isn't clear enough to answer it. Which chart border do you mean? Normal JFX 8 Charts? They generate their own legends. Or do you want a styled TextField? – SilverMonkey Aug 11 '17 at 12:36
-
I use JavaFX8.. – Vitaliy Denys Aug 11 '17 at 12:53
-
1I don't think the question is about the legend. More about bordered pane and such a question had been asked before: https://stackoverflow.com/questions/17288995/how-to-add-border-to-panel-of-javafx – Przemysław Długoszewski-Tamoń Aug 11 '17 at 12:56
1 Answers
2
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>

SedJ601
- 12,173
- 3
- 41
- 59