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.