Skip to content

Instantly share code, notes, and snippets.

@mkheck
Created March 1, 2013 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkheck/5066119 to your computer and use it in GitHub Desktop.
Save mkheck/5066119 to your computer and use it in GitHub Desktop.
Using an anonymous inner class for User Info column's cell factory. Associated blog post: https://blogs.oracle.com/javajungle/entry/how_to_pretty_up_your
userInfoCol.setCellFactory(new Callback<TableColumn<MTweet, MUser>,
TableCell<MTweet, MUser>>() {
@Override
public TableCell<MTweet, MUser> call(TableColumn<MTweet, MUser> param) {
return new TableCell<MTweet, MUser>() {
VBox vb;
Label userName;
Label screenName;
ImageView imgVw;
{
vb = new VBox();
vb.setAlignment(Pos.CENTER);
userName = new Label();
screenName = new Label();
imgVw = new ImageView();
imgVw.setFitHeight(50);
imgVw.setFitWidth(50);
vb.getChildren().addAll(imgVw, userName, screenName);
setGraphic(vb);
}
@Override
public void updateItem(MUser item, boolean empty) {
if (item != null) {
userName.setText(item.name());
screenName.setText("@" + item.screenName());
imgVw.setImage(item.icon());
}
}
};
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment