I was want have a table column with a button labeled "Add to Playlist". The row in the column represents a song. I have the following class:
private class ButtonCell extends TableCell<Record, Boolean> {
final Button cellButton = new Button("Add to PlayList");
ButtonCell(){
cellButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
// do something when button clicked
//playList.add(this.getTableRow().getItem());
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
super.updateItem(t, empty);
if(!empty){
setGraphic(cellButton);
}
}
}
EventHandler<ActionEvent> btnNewHandler =
new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
}
};
And I want to be able to do this 'playList.add(this.getTableRow().getItem());' Is there a way to do this?
The gist of the question is how do I get the information of a cell and add that information to an observable list?
Thanks