Localization JavaFX2.x TableView本地化

Localization JavaFX2.x TableView本地化,localization,tableview,javafx-2,Localization,Tableview,Javafx 2,当TableView控件不包含任何内容时,它将显示“表中无内容”。如何更改/本地化该字符串?给你 tableView.setPlaceholder(new Text("Your localized text here")); 如果没有数据,则表视图中不会显示任何内容 .table-row-cell:empty { -fx-background-color: lightyellow; } .table-row-cell:empty .table-cell { -fx-borde

当TableView控件不包含任何内容时,它将显示“表中无内容”。如何更改/本地化该字符串?

给你

tableView.setPlaceholder(new Text("Your localized text here"));

如果没有数据,则表视图中不会显示任何内容

.table-row-cell:empty {
    -fx-background-color: lightyellow;
}

.table-row-cell:empty .table-cell {
    -fx-border-width: 0px;
}

按照JavaFX的建议,最好是这样实现

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;
    }
}
当您准备更改本地化时,您需要的一切就是编辑您的属性文件。

Ha,它是一个节点:),我正在寻找一些字符串设置程序或本地化包。。谢谢
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());

    }
    ...
}