Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aberezkin/mtv-builder
This is a library that can build a FXML TableView using given model class.
https://github.com/aberezkin/mtv-builder
Last synced: 24 days ago
JSON representation
This is a library that can build a FXML TableView using given model class.
- Host: GitHub
- URL: https://github.com/aberezkin/mtv-builder
- Owner: aberezkin
- Created: 2016-08-11T02:48:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-02T02:28:17.000Z (over 8 years ago)
- Last Synced: 2024-11-10T15:51:03.427Z (3 months ago)
- Language: Java
- Homepage:
- Size: 3.91 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## How to use
First of all you need you need a model class with public getters and setters for all the fields you wany to be represented in the TableView.
public class Person {
private String firstName;
private String lastName;
private String email;
private int age;
public Person(String firstName,
String lastName, String email, int age) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.age = age;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
Note that naming convention is important. If a field is called `id` then getter shall be called `getId` and setter shall be called `setId`. If this requirement is not satisfied the field will not be represented in the TableView.Then to generate the TableView you just need to use `buildUpon(Class>)` method.
TableView personTable = ModelTableViewBuilder.buildUpon(Person.class);
And now you can populate it using `ObservableList`ObservableList data = FXCollections.observableArrayList(people);
personTable.setItems(data);
TableView is ready to be shown in the layoutcontainer.getChildren().add(personTable);
Here is what you get
[![Screenshot from 2016-08-11 12:38:44.png](https://s10.postimg.org/6ptry56d5/Screenshot_from_2016_08_11_12_38_44.png)](https://postimg.org/image/evbtwaulx/)