这里的场景是,tableview中有三列任务,组号和Status.Task号码都有字符串,组号也会有字符串,但是在状态列中我想要显示颜色填充的圆圈下面是我的代码。它没有任何错误,也没有显示圈子。
xml控制器类的一部分:
@FXML
private TableView<TaskSchData> taskListTable = new TableView<TaskSchData>();
@FXML
private TableColumn<TaskSchData, String> taskName;
@FXML
private TableColumn<TaskSchData, String> grpNo;
@FXML
private TableColumn<TaskSchData, String> statuscheck;
taskName.setCellValueFactory(new PropertyValueFactory<TaskSchData, String>("taskName"));
grpNo.setCellValueFactory(new PropertyValueFactory<TaskSchData, String>("grpNo"));
statuscheck.setCellValueFactory(new PropertyValueFactory<TaskSchData, String>("statuscheck"));
TaskSchData taskSchData = new TaskSchData(data.gettaskName(), data.getsuffix(),circle);
TaskSchData类:
public final SimpleStringProperty taskName;
public final SimpleStringProperty grpNo;
public Circle status ;
Circle circle = new Circle(150, Color.web("red", 0.05));
public TaskSchData(String taskName, String groupNo,Circle cir) {
this.taskName = new SimpleStringProperty(taskName);
this.grpNo = new SimpleStringProperty(groupNo);
this.status=cir;
}
public Circle getStatus() {
return status;
}
public String getTaskName() {
return taskName.get();
}
public void setTaskName(String taskName) {
this.taskName.set(taskName);
}
public void setStatus(Circle img) {
this.status=img;
}
public SimpleStringProperty taskNameProperty() {
return taskName;
}
public SimpleStringProperty grpNoProperty() {
return grpNo;
}
FXML:
<TableColumn sortable="false" text="Tasks" fx:id="taskName">
<minWidth>
<Long fx:value="50" />
</minWidth>
<prefWidth>
<Long fx:value="150" />
</prefWidth>
</TableColumn>
<TableColumn sortable="false" text="Group No" fx:id="grpNo">
<prefWidth>
<Long fx:value="75" />
</prefWidth>
</TableColumn>
<TableColumn text="Status" fx:id="statuscheck">
<prefWidth>
<Long fx:value="100" />
</prefWidth>
</TableColumn>
请在此帮忙。