When TableView control contains no content, it displays "No content in table". How to change/localize that string?
Here you go
tableView.setPlaceholder(new Text("Your localized text here"));
no things display in table view if no data
.table-row-cell:empty {
-fx-background-color: lightyellow;
}
.table-row-cell:empty .table-cell {
-fx-border-width: 0px;
}
Following JavaFX recommendation it'd be better to implement like this
Model.java
class Model {
private final ObjectProperty<Text> placeholderProperty;
Model(ResourceBundle resourceBundle) {
placeholderProperty = new SimpleObjectProperty<>(new Text(resourceBundle.getString("placeholderTextFromLocalizationProperties")));
}
...
ObjectProperty<Text> placeholderProperty() {
return placeholderProperty;
}
}
Controller.java
class Controller implements Initializable {
private Model model;
@FXML
private TableView tableView;
...
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
model = new Model(resourceBundle);
tableView.setPlaceholder(model.placeholderProperty().get());
}
...
}
When you are about to change localization everything you need is to edit your property file.
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