JDK-4803783 : Reopen 4425334: drag in JList requires two mouse gestures
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-01-15
  • Updated: 2003-01-16
  • Resolved: 2003-01-16
Related Reports
Duplicate :  
Description

Name: jk109818			Date: 01/15/2003


FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)


FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]

ADDITIONAL OPERATING SYSTEMS :
Should be applicable to all OSs

A DESCRIPTION OF THE PROBLEM :

To drag an object from a JList it is required that the
object is first selected, then, in a second mouse gesture,
dragged. This is contrary to the expected user experience
(e.g. in Windows Explorer) where you can select and drag
in a single gesture. Not that the list selection event
should not be fired until MOUSE UP to enable dragging an
object to another pane that might switch contents due to a
list selection event (c.f. the tree and directory panes of
Windows Explorer).

This is a duplicate of 4425334 which should not have been
closed.

This IS a bug, even if by design! Compare this with Windows, 
where you can click and drag an object in a list which was 
not previously the selection.


STEPS TO REPRODUCE:
1) Compile the below 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.



SOURCE 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();
	}
}




REPRODUCIBILITY :
This bug can be reproduced always.
(Review ID: 178852) 
======================================================================

Comments
EVALUATION Closing as a duplicate of the OPEN bug 4521075, one of our most popular vote getters. ###@###.### 2003-01-16
2003-01-16