1
從以下FXML:爲什麼TableView/TableColumn不可編輯?
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<VBox spacing="10" xmlns:fx="http://javafx.com/fxml">
<Label fx:id="_lru" styleClass="wizard-title-centered" />
<Label fx:id="_prompt" styleClass="wizard-label" />
<TableView fx:id="_tableVw" maxWidth="560" prefHeight="200" editable="true">
<columns>
<TableColumn fx:id="_name" prefWidth="220" editable="false" />
<TableColumn fx:id="_partNum" prefWidth= "80" editable="false" />
<TableColumn fx:id="_serialNum" prefWidth= "84" editable="true" />
<TableColumn fx:id="_calibrationDate" prefWidth="120" editable="true" />
<TableColumn fx:id="_available" prefWidth= "40" editable="false" />
</columns>
</TableView>
<Text fx:id="_note" wrappingWidth="550" styleClass="wizard-label" />
</VBox>
關聯到下面的Java類:
public class Page extends AbstractPage<Data> implements Initializable {
@FXML private Label _lru;
@FXML private Label _prompt;
@FXML private TableView<Record> _tableVw;
@FXML private TableColumn<Record, String> _name;
@FXML private TableColumn<Record, String> _partNum;
@FXML private TableColumn<Record, String> _serialNum;
@FXML private TableColumn<Record, LocalDate> _calibrationDate;
@FXML private TableColumn<Record, Boolean> _available;
@FXML private Text _note;
@Override
public void initialize(URL location, ResourceBundle resources) {
_lru .setText(_worker.getData()._tpsSoftName);
_prompt .setText(I18n.get("EXTERNAL_RC_PROMPT" ));
_name .setText(I18n.get("EXTERNAL_RC_NAME" ));
_partNum .setText(I18n.get("EXTERNAL_RC_PARTNUM" ));
_serialNum .setText(I18n.get("EXTERNAL_RC_SERIALNUM"));
_calibrationDate.setText(I18n.get("EXTERNAL_RC_CALIB" ));
_available .setText(I18n.get("EXTERNAL_RC_AVAILABLE"));
_note .setText(I18n.get("EXTERNAL_RC_NOTE" ));
_name .setCellValueFactory(new PropertyValueFactory<Record, String> ("name"));
_partNum .setCellValueFactory(new PropertyValueFactory<Record, String> ("partNum"));
_serialNum .setCellValueFactory(new PropertyValueFactory<Record, String> ("serialNum"));
_calibrationDate.setCellValueFactory(new PropertyValueFactory<Record, LocalDate>("calibrationDate"));
_available .setCellValueFactory(new PropertyValueFactory<Record, Boolean> ("available"));
_calibrationDate.setCellFactory(
new Callback<TableColumn<Record,LocalDate>, TableCell<Record,LocalDate>>() {
@Override public TableCell<Record,LocalDate> call(TableColumn<Record,LocalDate> c) {
return new DatePickerCell<>(); }});
_available.setCellFactory(
new Callback<TableColumn<Record,Boolean>, TableCell<Record,Boolean>>() {
@Override public TableCell<Record,Boolean> call(TableColumn<Record,Boolean> c) {
return new CheckBoxTableCell<>(); }});
}
@Override
public void processDone(boolean successfully) {
_tableVw.getItems().setAll(_worker.getData()._resources);
}
}
雙擊SERIALNUM列時,「校準日期」一欄是編輯不激活基礎TextField。 爲什麼?