javafx.scene.control.TableColumn
This node takes the attributes of the javafx.scene.control.TableColumn see javafx.scene.control.TableColumn.
There is no content for a TableColumn
Used to create a TableColumn for use in a TableView. A tableColumn ties a property from a data set to a specific column in a TableView and defines the column header.
import groovyx.javafx.GroovyFX
import javafx.scene.paint.Color;
import groovyx.javafx.SceneGraphBuilder
import javafx.scene.control.*;
import javafx.scene.control.table.*;
import javafx.beans.property.StringProperty;
class Person {
public Person(String first, String last, String city, String state) {
setFirstName(first);
setLastName(last);
setCity(city);
setState(state);
}
private StringProperty firstName;
public void setFirstName(String value) { firstNameProperty().set(value); }
public String getFirstName() { return firstName == null? "" : firstName.get(); }
public StringProperty firstNameProperty() {
if (firstName == null) firstName = new StringProperty();
return firstName;
}
private StringProperty lastName;
public void setLastName(String value) { lastNameProperty().set(value); }
public String getLastName() { return lastName == null? "" : lastName.get(); }
public StringProperty lastNameProperty() {
if (lastName == null) lastName = new StringProperty();
return lastName;
}
private StringProperty city;
public void setCity(String value) { cityProperty().set(value); }
public String getCity() { return city == null? "" : city.get(); }
public StringProperty cityProperty() {
if (city == null) city = new StringProperty();
return city;
}
private StringProperty state;
public void setState(String value) { stateProperty().set(value); }
public String getState() { return state == null? "" : state.get(); }
public StringProperty stateProperty() {
if (state == null) state = new StringProperty();
return state;
}
}
def data = [
new Person('Jim', 'Clarke', 'Orlando', 'Fl'),
new Person('Jim', 'Connors', 'Long Island', 'NY'),
new Person('Eric', 'Bruno', 'Long Island', 'NY'),
]
//todo cell factory
GroovyFX.start({
def sg = new SceneGraphBuilder();
sg.stage(
title: "Table Example (Groovy)",
width: 650, height:450,
visible: true,
) {
scene(fill: lightgreen ) {
tableView(items: data) {
tableColumn(text: "First Name", property: 'firstName')
tableColumn(text: "Last Name", property: 'lastName')
tableColumn(text: "City", property: 'city')
tableColumn(text: "State", property: 'state')
}
}
}
});
|