我需要将TableView
中的每个单元格转换为JFXTextArea
。前4列是完美的,让我输入文字。但第5列只是不可点击。当我点击它时,整个行都被选中。如何使第5列的行为与前4列相似?
FXMLController.java
@FXML
private TableView<Person> table1;
TableColumn indexCol = new TableColumn("S. No.");
TableColumn desCol = new TableColumn("Description");
TableColumn quantityCol = new TableColumn("Quantity");
TableColumn unitCol = new TableColumn("Unit/(SGD)");
TableColumn totalCol = new TableColumn("Total (SGD)");
void fillTable(){
indexCol.setSortable(false);
desCol.setSortable(false);
quantityCol.setSortable(false);
unitCol.setSortable(false);
totalCol.setSortable(false);
indexCol.setPrefWidth(50);
table1.getColumns().addAll(indexCol, desCol, quantityCol, unitCol ,totalCol);
ObservableList<Person> data;
data = FXCollections.observableArrayList(
new Person("Jack", "", "","", ""),
new Person("Tom", "", "","", "")
);
indexCol.setCellValueFactory(
new PropertyValueFactory<Person,String>("firstName")
);
desCol.setCellValueFactory(
new PropertyValueFactory<Person,String>("lastName")
);
quantityCol.setCellValueFactory(
new PropertyValueFactory<Person,String>("email")
);
unitCol.setCellValueFactory(
new PropertyValueFactory<Person,String>("remark")
);
totalCol.setCellValueFactory(new PropertyValueFactory<Person,String>("total"));
table1.setItems(data);
}
Person.java
public class Person {
private JFXTextArea firstName;
private JFXTextArea lastName;
private JFXTextArea email;
private JFXTextArea remark;
private JFXTextArea total;
Person(String fName, String lName, String email, String value, String total1) {
this.firstName= new JFXTextArea();
this.firstName.setText(fName);
this.firstName.setEditable(false);
this.remark = new JFXTextArea();
this.lastName = new JFXTextArea();
this.email = new JFXTextArea();
this.total = new JFXTextArea();
}
public JFXTextArea getFirstName() {
return firstName;
}
public void setFirstName(JFXTextArea fName) {
this.firstName = fName;
}
public JFXTextArea getLastName() {
return lastName;
}
public void setLastName(JFXTextArea fName) {
this.lastName = fName;
}
public JFXTextArea getEmail() {
return email;
}
public void setEmail(JFXTextArea fName) {
this.email = fName;
}
public JFXTextArea getRemark() {
return remark;
}
public void setRemark(JFXTextArea remark) {
this.remark = remark;
}
public void settotal(JFXTextArea fName) {
this.total = fName;
}
public JFXTextArea gettotal() {
return total;
}
}