JDK-4425334 : Unable to drag from JList, if mouse btn not released till it's dropped on target
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P2
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2001-03-14
  • Updated: 2001-04-13
  • Resolved: 2001-04-12
Related Reports
Relates :  
Description
Unable to drag and drop a selected item from JList, if mouse button is not released till it's dropped on the target.

% java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b55)
Java HotSpot(TM) Client VM (build 1.4beta-B55, mixed mode)

Sample testcase code :

import javax.swing.*;
import javax.swing.plaf.basic.*;

import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class BugWithDnDSwing extends JFrame {

	JPanel panel;

	private JTextField tfSource;
	private JTextField tfDest;

	private JList listSource;
	private JList listDest;

	public BugWithDnDSwing() {
		super("BugWithDnDSwing");
		setSize(400,400);
		panel = new JPanel();
		panel.setLayout( null );

		tfDest = new JTextField();
		tfDest.setBounds(150,40,100,20);
		panel.add(tfDest);

		String[] data = {"one", "two", "three", "four"};
		listSource = new JList(data);
		listSource.setBounds(10,40,100,60);
		listSource.setDragEnabled(true);
		panel.add(listSource);

		panel.setVisible(true);
		getContentPane().add(panel);
		setVisible(true);

		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent ae) {
				System.exit(0);
			}
		});
	}

	public static void main(String[] args) {
		new BugWithDnDSwing();
	}
}

To reproduce :

1) Compile the above code and execute it.
2) Press LEFT mouse button on a non-selected item of JList.
3) Start dragging without releasing the mouse button.

You will see that nothing gets dragged.

NOTE : This is reproducible on all platforms.

Comments
PUBLIC COMMENTS It is still reproducible.
10-06-2004

EVALUATION This was a regression caused by 4403474. I discovered this (and fixed it) while fixing 4416547. JList, JTree, JTable, and JFileChooser were all broken because they depended upon the bug in TransferHandler of always returning COPY as the source action. The various TransferHandler implementations in the basic package now implement getSourceActions to return COPY which properly reflects their capabilities. The fix has already been integrated in yesterdays integration so I'm marking this integrated. timothy.prinzing@eng 2001-03-14 Moving the status to fixed as dragging from a JList works fine for me, and we are integrating today. I'm certain this was already integrated though. timothy.prinzing@eng 2001-03-27 Apparently the actual regression wasn't noticed. After reading the description of the bug again I see the report did not describe a bug in the first place. To initiate a drag, you must press over a SELECTED item and drag a few pixels before a drag gesture is recognized. timothy.prinzing@eng 2001-04-12
12-04-2001