Khi điều khiển TableView không chứa nội dung, nó hiển thị "Không có nội dung trong bảng". Làm thế nào để thay đổi/bản địa hóa chuỗi đó?JavaFX 2.x Bản địa hóa TableView
10
A
Trả lời
21
Ở đây bạn đi
tableView.setPlaceholder(new Text("Your localized text here"));
1
không điều hiển thị trong xem bảng nếu không có dữ liệu
.table-row-cell:empty {
-fx-background-color: lightyellow;
}
.table-row-cell:empty .table-cell {
-fx-border-width: 0px;
}
1
Sau JavaFX giới thiệu nó muốn được tốt hơn để thực hiện như thế này
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());
}
...
}
Khi bạn sắp thay đổi nội địa hóa mọi thứ bạn cần là chỉnh sửa tệp thuộc tính của bạn.
Ha, đó là nút :) và tôi đang tìm kiếm một số chuỗi setter hoặc gói nội địa hóa .. cảm ơn! – Kamil