「プレイリストに追加」というラベルの付いたボタンを含む表の列が必要でした。列の行は曲を表します。私は次のクラスを持っています:
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) {
}
};
そして、この「playList.add(this.getTableRow().getItem());」を実行できるようにしたいです。これを行う方法はありますか?
質問の要点は、セルの情報を取得し、その情報を監視可能なリストに追加するにはどうすればよいですか?
ありがとう