Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Generated Object

javafx.scene.control.TableView

Attributes

This node takes the attributes of the javafx.scene.control.TableView see javafx.scene.control.TableView.

Content

If the content is a tooltip, the TableView's tooltip will be set to the Tooltip.

TableView takes a series of tableColumn objects to define each column of the table.

Usage

Used to create a TableView

Examples

Code Block
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')
             }
         }
    }
});