Jason S
Jason S

Reputation: 189686

java/swing: showing potential drop target rows in a JTable

I want to implement DropTargetListener with a JTable as a target. This is roughly what I would like to do:

@Override public void dragOver(DropTargetDragEvent event) {
    MyItem item = getMyItemFromTransferable(); 
    int nrows = item.getTableRowsRequiredForDrop();
    // now highlight rows in the table under the drop cursor.
}   

How can I figure out which row in the JTable is the row under the cursor where the DropTargetDragEvent is?

Upvotes: 1

Views: 565

Answers (1)

Michael Myers
Michael Myers

Reputation: 191945

I believe it would be:

int row = myTable.rowAtPoint(event.getLocation());

Upvotes: 2

Related Questions