A.Sharma A.Sharma - 6 months ago 12
Java Question

Increase Height of TableRow on Drag

I'm working on a JavaFX app via SceneBuilder and I'm trying to work with adding functionality to the TableView. My current task is to allow the user to drag and increase the height of each TableRow on drag. Essentially, I'm trying to make it function like Excel.

Java Code

tv.setRowFactory(t -> {

TableRow tr = new TableRow();

tr.setOnMouseDragged(event -> {

return tr;


I tested the getY() function on drag and saw that it was iteratively increasing as I moved down on the screen.

I tried searching for a way to do this, but I couldn't find any leads on this. If you have a link to some documentation on the methods that are required, that would be great as well.

Also, if SceneBuilder has a built in way to allow for this functionality in a TableView, that may work as well.


Try the following:

table.setRowFactory(t -> {
            final TableRow tr = new TableRow();
            final double prefHeight = 54;

            tr.setOnMouseDragged(event -> {
                final double newHeight = event.getY();
                if(newHeight < prefHeight) {

            return tr;