Skip to content

Instantly share code, notes, and snippets.

@incepttechnologies
Created October 9, 2013 22:51
Show Gist options
  • Save incepttechnologies/6909893 to your computer and use it in GitHub Desktop.
Save incepttechnologies/6909893 to your computer and use it in GitHub Desktop.
TableView -initialize
public void initialize(URL url, ResourceBundle rb) {
System.out.println("initialize");
sort();
initializeTable();
pageCount = getPageCount(persons.size(), itemsPerPage);
System.out.println("pageCount=" + pageCount);
pagination.setPageCount(pageCount);
pagination.currentPageIndexProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
System.out.println("Pagination Changed from " + oldValue + " , to " + newValue);
currentPageIndex = newValue.intValue();
updatePersonView();
}
});
save.setOnAction(new javafx.event.EventHandler<javafx.event.ActionEvent>() {
@Override
public void handle(javafx.event.ActionEvent t) {
persons.add(new Person(idTxt.getText(), nameTxt.getText(), (new Integer(ageTxt.getText())).intValue()));
sort();
updatePersonView();
idTxt.setText(null);
nameTxt.setText(null);
ageTxt.setText(null);
}
});
id.setOnAction(new javafx.event.EventHandler<javafx.event.ActionEvent>() {
@Override
public void handle(javafx.event.ActionEvent t) {
sort();
if (order) {
Collections.reverse(persons);
}
System.out.println(" order = " + order + "; data = " + persons);
order = !order;
id.setGraphic((order) ? upImg : downImg);
updatePersonView();
System.out.println(" comparator called");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment