Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX 2.x TableView localization

When TableView control contains no content, it displays "No content in table". How to change/localize that string?

like image 748
Kamil Avatar asked Jul 04 '12 18:07

Kamil


3 Answers

Here you go

tableView.setPlaceholder(new Text("Your localized text here"));
like image 191
Uluk Biy Avatar answered Oct 07 '22 04:10

Uluk Biy


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;
}
like image 20
Vu Truong Avatar answered Oct 07 '22 04:10

Vu Truong


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.

like image 30
Andreas Avatar answered Oct 07 '22 04:10

Andreas