Skip to content

Instantly share code, notes, and snippets.

@aalmiray
Created August 6, 2014 16:22
Show Gist options
  • Save aalmiray/550874cdb2c539cc72bb to your computer and use it in GitHub Desktop.
Save aalmiray/550874cdb2c539cc72bb to your computer and use it in GitHub Desktop.
Glazedlists + JavaFX ?!?
package griffon.plugins.glazedlists;
import ca.odell.glazedlists.gui.TableFormat;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
public class Test extends Application {
public static void main(String[] args) throws Exception {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
ObservableList<Person> people = FXCollections.observableArrayList(
new Person("Jamie", "Hyneman"),
new Person("Adam", "Savage"),
new Person("Tory", "Belleci"),
new Person("Kari", "Byron"),
new Person("Grant", "Imahara")
);
TableFormat<Person> format = new DefaultTableFormat<>(new String[]{"name", "lastname"});
TableViewModel<Person> model = new DefaultTableViewModel<>(people, format);
TableView<Person> tableView = new TableView<>();
model.attachTo(tableView);
Scene scene = new Scene(tableView);
stage.setTitle("MythBusters");
stage.setScene(scene);
stage.sizeToScene();
stage.show();
}
public static class Person {
private final String name;
private final String lastname;
public Person(String name, String lastname) {
this.name = name;
this.lastname = lastname;
}
public String getName() {
return name;
}
public String getLastname() {
return lastname;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment