So, first things first, I have achieved what I wanted, and that is, display some amount of text in the center of a "zone". Screenshot (upper right corner):
Now, the problem I have is how I achieved this... This is the FXML extract for the whole tab:
<Tab text="Statistics" closable="false">
<SplitPane orientation="VERTICAL" dividerPositions="0.5">
<SplitPane orientation="HORIZONTAL" dividerPositions="0.5">
<GridPane gridLinesVisible="false">
<!-- snip -->
</GridPane>
<!-- HERE -->
<BorderPane>
<center>
<Label text="No information"/>
</center>
</BorderPane>
</SplitPane>
<TableView fx:id="stats">
<!-- snip -->
</TableView>
</SplitPane>
</Tab>
As you can see, in order to achieve something which intuitively should be simple (display some text in the center of a zone), I had to create a BorderPane
and put a Label
in its <center>
; and I didn't even have to specify that the text on the label should be centered...
The other things I have tried are:
- put the
Label
itself: then the divider of theScrollPane
would be blatanly ignored; the left side would expand to the full width of theScene
(is that it?) minus the width of the divider plus the text of the label, and what is more, the text would be at the top of the zone; - enclose it with an
AnchorPane
: while this would indeed keep the size of the zone, the text would appear on the top left corner and not in the center.
Is there an easier solution than the above?