I found one possible solution. You are binding mouse listeners so that you can lie to the isCellSelected call while calling canStartDrag.
Subclass of JTable (or in my case JXTreeTable). In the constructor, call this:
private void setupSelectionDragHack() { // Bracket the other mouse listeners so we may inject our lie final MouseListener[] ls = getMouseListeners(); for (final MouseListener l : ls) { removeMouseListener(l); } addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { // NOTE: it might not be necessary to check the row, but... I figure it safer maybe? mousingRow = rowAtPoint(e.getPoint()); mousingInProgress = true; } }); for (final MouseListener l : ls) { addMouseListener(l); } addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { mousingInProgress = false; } }); }
And then you need the following:
@Override public boolean isCellSelected(final int row, final int column) { if (mousingInProgress && row == mousingRow) {
It's an ugly hack in many ways, but ... for now it works.
source share