Reputation:
I am making a Kanban board, I have a column where inside of it, it's divided using a grid pane between the header and a list of cards below. I am building this using a scene builder.
So the hierarchy is
Anchor Pane(column) -> Gridpane(Seperate header and cards) -> Vbox(where I place my list of cards) -> AnchorPane(cards) -> Button(each card has a button)
When I press the button on the card, I want it to remove the card that I clicked on.
I have done the following
@FXML
public void delete() {
Parent parent = button.getParent();
col1.getChildren().remove(parent); //col1 is the column
}
However nothing happens when I press the button, the card does not get deleted and I do not know why. If someone can help me out that would be great.
Upvotes: 3
Views: 161
Reputation: 12751
Try changing the code as follows:
@FXML
public void delete() {
Parent card = button.getParent();
((VBox) card.getParent()).getChildren().remove(card);
}
Upvotes: 3