CTRL key with drag'n'drop
Hi,
I am trying to implement a drag'n'drop system. What I need to do is drag multiple items from a JList to the tabs of a JTabbedPane. It works fine, mainly, but I've had to override the UI of the JList to disable the annoying drag-selection feature:
class NoDragListUI extends BasicListUI
{
protected MouseInputListener createMouseInputListener()
{
return new NoDragMouseInputHandler();
}
class NoDragMouseInputHandler extends BasicListUI.MouseInputHandler
{
public void mouseDragged(MouseEvent e)
{
// Normally dragging the mouse on a JList will make
// the selection "follow" the mouse. This clashes
// with the drag'n'drop, so this function has been
// overridden to do nothing.
}
}
}
So far so good. It all works pretty good now, apart from the following two glitches:
1) If I use the CTRL key to make multiple selections in the list, begin dragging, then let go of the CTRL key, the drag is cancelled.
2) If I use the CTRL key to make multiple selections, then let go of CTRL before the mouse-button is released for the last selection, then start dragging, the drag "locks" on, and I can't drop (I have to hit ESCape to cancel the drag).
Basically, I don't want the CTRL key to have anything to do with the drag'n'drop. Is there a way to catch these CTRL-related drag'n'drop behaviours and override them to do nothing?

