Well It has been quiet long time but I found it would be time for me to blog small post about making the table cell selection in JavaFX. Normally TableView has facility to select the cell or row by using Ctrl,Command (Shortcut Key) and Shift button. You can easily select the data using your keyboards. But when it comes for ease to user interaction using mouse is vital. So today we will go through how to create selection of data by mouse. Lets categorize them in two parts.

TableView has the default selection mode set to SelectionMode.SINGLE and we will need to change this mode to multiple by using

For making the TableRow selection in sequence we are going to use simple Mouse Press action. Actually the Table Data (Cells,Rows) has the property of mouse like drag,press,click. So to make the selection of data possible we will have to make use of draggable event of TableRow or TableCell. Lets get in with the TableRow selection by mouse.

TableRow Selection

For the demo we are going to use the Person as an Object data with few properties.

By using the rowFactory implementation we can easily make the selection of the Row by simple using only Mouse Movement. Similar to Row selection we can work on the Cell Selection as well.

TableCell Selection

Regarding this multi-selection we can press the “Ctrl” Key for selecting more rows/cell with existing data selected.

A sample demo is given in the youtube you can check that out : http://youtu.be/lf41ccYPToI
Source Code of the Demo is here : https://github.com/privatejava/javafx-tableview-data-selection

Enjoy Coding. 🙂