Java Reference
In-Depth Information
GroovyFX.start {
new SceneGraphBuilder().stage(visible: true) {
scene {
tableView(items: persons) {
tableColumn(property: "name", text: "Name", prefWidth: 160)
tableColumn(property: "age", text: "Age", prefWidth: 70)
tableColumn(property: "gender", text: "Gender", prefWidth: 90)
tableColumn(property: "dob", text: "Birth", prefWidth: 100,
type: Date,
converter: { d -> return dateFormat.format(d) })
}
}
}
}
Notice that the code to display the table is almost as short as the code to set up the data. The converter in
the last column to format the
Date
is a one-line operation in Groovy, but requires a
CellValueFactory
with an
implementation of a
Callback
interface, which is several lines of Java code saved.
Figure
13-8
displays the result of running this table application in Groovy.
Figure 13-8.
Groovy Table demo with famous women in computers listed
Search WWH ::
Custom Search