United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7049024 DnD fails with JTextArea and JTextField
JDK-7049024 : DnD fails with JTextArea and JTextField

Details
Type:
Bug
Submit Date:
2011-05-27
Status:
Closed
Updated Date:
2013-06-26
Project Name:
JDK
Resolved Date:
2011-11-16
Component:
client-libs
OS:
linux_ubuntu,generic
Sub-Component:
javax.swing
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7,8
Fixed Versions:

Related Reports
Backport:
Backport:

Sub Tasks

Description
FULL PRODUCT VERSION :

The problem exists on latest jdk. For now, the internal java8 build is still breaking the testcase.

openjdk version "1.8.0-internal"
OpenJDK Runtime Environment (build 1.8.0-internal-zhouyx_2011_08_01_11_00-b00)
OpenJDK Client VM (build 21.0-b14, mixed mode)

It is first reported on Java7 b142,  and I can see the problem exists on java6 as well.


ADDITIONAL OS VERSION INFORMATION :
Linux  2.6.38-8-generic #42-Ubuntu SMP i686 i386 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
    I have a testcase related to DnD failure with JTextArea and JTextField on linux. The
testcase is as follows:

/*
 * DnDTest.java
 */
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JTextArea;
import javax.swing.JTextField;


public class DnDTest extends Frame {
	Component c;
	public DnDTest() {
		super("Single Frame --- AWT Frame");
		super.setBackground(Color.gray);
		
		// set layout here.
		setLayout(new FlowLayout());
		
		c = new JTextArea("JTextArea component");
		c.setPreferredSize(new Dimension(400, 100));
		add(c);
		
		c = new JTextField("JTextField component(No IM)");
		c.setPreferredSize(new Dimension(400, 20));
		add(c);
		
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent event) {
				System.exit(0);
			}
		});
		setSize(850, 360);
		setVisible(true);
	}
	
	public static void main(String[] args) {
		new DnDTest();
	}
}


Reproduce steps:
1. Run the testcase
2. Open a new file with gedit and input some words like "abcde"
3. Drag "abcde" into JTextField and drop it there.
4. Once more, drag "abcde" into JTextField and then move out of the Frame (keep draging) and drag into JTextField again and drop it.

Expectation:
The second DnD inputs another "abcde" into JTextField.

Result:
The second DnD inputs nothing into JTextField.

Investigation:
The JTextArea as well has this problem, and in step 4, if we drag "abcde" over JTextField and then drop into JTextArea, nothing
is input into JTextArea either. However, if "abcde" is drag into JTextField or JTextArea directly or when JTextArea/Field are
empty as in step 2, it works.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the testcase with b143
2. Open a new file with gedit and input some words like "abcde"
3. Drag "abcde" into JTextField and drop it there.
4. Once more, drag "abcde" into JTextField and then move out of the Frame (keep draging) and drag into JTextField again and drop it

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The second DnD inputs another "abcde" into JTextField.
ACTUAL -
The second DnD inputs nothing into JTextField.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/*
 * DnDTest.java
 */
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JTextArea;
import javax.swing.JTextField;


public class DnDTest extends Frame {
	Component c;
	public DnDTest() {
		super("Single Frame --- AWT Frame");
		super.setBackground(Color.gray);
		
		// set layout here.
		setLayout(new FlowLayout());
		
		c = new JTextArea("JTextArea component");
		c.setPreferredSize(new Dimension(400, 100));
		add(c);
		
		c = new JTextField("JTextField component(No IM)");
		c.setPreferredSize(new Dimension(400, 20));
		add(c);
		
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent event) {
				System.exit(0);
			}
		});
		setSize(850, 360);
		setVisible(true);
	}
	
	public static void main(String[] args) {
		new DnDTest();
	}
}
---------- END SOURCE ----------
Additional details from the submitter:

I haven't tested it with earlier version of JDK6. According to the investigation I did when I tried to fix it, I think
it never worked on JDK6.

The problem seems to be like this: dragExit calls setDropLocation and give an argument meaning "this
is not a real drop". While the call tree goes down, the information is lost, and updateSystemSelection treat
it as a real drop and updated something, and the string which is not dropped is cleared.

                                    

Comments
EVALUATION

Sent mail to the submitter to find out what release (including build number) that they were using. Selecting the value in the pulldown is useful to get the report the the right area, but not knowing the output of 'java -version' makes it hard to know where the test is really failing. Is it build 5 of JDK7?
                                     
2011-05-31
Verified with the b21 regression test runs http://aurora.ru.oracle.com/functional/faces/RunDetails.xhtml?names=99201.STT.JDK8.PROMOTION.REGRESSION%2B1.8.0b21-linux-x64-64_j2se_javax_gui
                                     
2013-04-17



Hardware and Software, Engineered to Work Together