I know the following problem is a bit of a luxury problem:
I would like to keep the initialize of my FXML Controller as clean as possible, and therefore I would like to set the placeholder of my TableView in the FXML file (as I think it is the best place to keep it, because it is just a property and in my case also a constant). I already tried to set it in the FXML file like this:
<TableView placeholder="Some text">
This obviously does not work, because the placeholder property expects a Node. That is why I set the placeholder like this in the initialize of the FXML controller:
Label placeholder = new Label();
placeholder.setText("Some text");
tableview.setPlaceholder(placeholder);
This works, but as I said, I would like to manage this from the FXML file only. Some my question is:
How can I set the placeholder from within the FXML file?
Note: please let me know if this i even possible, because when it is not, I will fill a feature request (with a low priority of course!).
Quite simple, just the usual FXML Syntax:
<BorderPane xmlns:fx="http://javafx.com/fxml/1">
<center>
<TableView>
<placeholder>
<Label text="some text"/>
</placeholder>
</TableView>
</center>
Note: Not everything is a primitive value (can be expressed inline) and therefore needs its own element.
I already found the answer using this question: Styling a JavaFX 2 button using FXML only - How to add an image to a button?
The graphic tag triggered the idea to do it like this:
<TableView>
<placeholder><Label text="Some Text"></Label></placeholder>
</TableView>
And luckily it works! I hope I helped some of you too. Also, sorry for asking this question too quickly.
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