I am quite new at Scala. I use a tableView that has the custom type "Constraint", and I need to iterate it by the row.
Here is where I have gotten so far:
class ConstraintView(val stage : Stage) {
var obs : ObservableBuffer[Constraint]=ObservableBuffer()
var listConst : List[ConstraintTrait]=List()
val checkColumn=new TableColumn[Constraint, java.lang.Boolean] {
text = ""
cellValueFactory=_.value.initialSelection.delegate
}
checkColumn.setCellFactory(CheckBoxTableCell.forTableColumn(checkColumn))
stage.title="Constraint Table View"
stage.scene=new Scene {
val tab=new TableView[Constraint](obs) {
editable=true
columns ++=List(checkColumn,
new TableColumn[Constraint, String] {
text="Constraint Name"
cellValueFactory=_.value.constraintNameProp
},
new TableColumn[Constraint, String] {
text = "Result"
cellValueFactory=_.value.resultProp
}
)
}
content=tab
}
In Java, you would do
for (Constraint c : tab.getItems()) {
// do something with c
}
or
tab.getItems().forEach(c -> {
// do something with c
});
I don't know Scala, but perhaps this is enough for you to be able to translate.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.