How to delete row from table column javafx

Pim

enter image description here

These are my table columns Course and Description. If one clicks on a row (the row becomes 'active'/highlighted), and they press the Delete button it should remove that row, how do I do this?

The code for my Course column: (and what event listener do I add to my delete button?)

@SuppressWarnings("rawtypes")
TableColumn courseCol = new TableColumn("Course");
courseCol.setMinWidth(300);
courseCol.setCellValueFactory(new PropertyValueFactory<Courses, String>("firstName"));

final Button deleteButton = new Button("Delete");

deleteButton.setOnAction(.....
James_D

Just remove the selected item from the table view's items list. If you have

TableView<MyDataType> table = new TableView<>();

then you do

deleteButton.setOnAction(e -> {
    MyDataType selectedItem = table.getSelectionModel().getSelectedItem();
    table.getItems().remove(selectedItem);
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to delete a JavaFx TableView Row

Delete a row from Parse Table

how to delete one column and row from jagged array in c#

How to delete selected row from TableView? (JavaFX with FXML)

How to delete a row from a table

How to delete a single row from the table on clicking the icon/button

How to build a query from a column centric table and a row centric table?

How to delete a row from a table in SQL Server using PowerShell script?

how to delete a row from table using Angular5?

ReactJs how do i delete a row from a table?

How to delete a row and a column

External table how to delete newline char from the end of each row

How to delete selected column from table?Angular?

Codeigniter - How to delete a row from a table but only once?

Clean HTML table, add column from next row value, then delete that row

Delete a row from sqlite table

How to delete row from table without delete a row from referenced table?

Delete row from dynamic table

How to delete specific table row from backend and frontend?

How to delete a column in a table?

How to delete data from Mongodb and table row at a same time

How to delete repeated value from all the row present in a column of mysql

How to delete a single row from the table fast?

How to delete the duplicates from the table using row_number() in psql?

How to delete row from table using javascript?

How to delete last row from table in xslt

how to delete a row from the table with a button on react?

How to delete a row from a HTML table with React?

How to get row value from table when delete button is clicked?