United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4513715 : JTextComponent: DnD from and to same region clobbers selection & pastes nothing

Details
Type:
Bug
Submit Date:
2001-10-11
Status:
Closed
Updated Date:
2002-06-13
Project Name:
JDK
Resolved Date:
2002-04-27
Component:
client-libs
OS:
generic
Sub-Component:
javax.swing
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.1 (hopper)

Related Reports

Sub Tasks

Description
Selecting text and then dragging and dropping that text within the selected region of the same text component causes the selected text to be clobbered and nothing to be pasted. Such an operation should do nothing.

Try the following test case:
Highlight all of the first line.
Begin a drag operation by dragging the text from the first line.
Now drop somewhere into the original selected region.
The text dissapears.

The expected result is that nothing should happen. The text should not be clobbered.

import javax.swing.*;
import java.awt.*;

public class ClobberTest extends JFrame {

    public ClobberTest() {
        JTextArea ta = new JTextArea();
        ta.append("This is the text to drag.");
        ta.append("\nThis is some other text.");
        ta.setDragEnabled(true);
        getContentPane().add(new JScrollPane(ta));
    }

    public static void main(String[] args) {
        ClobberTest t = new ClobberTest();
        t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        t.setSize(400, 400);
        t.setVisible(true);
    }
}

                                    

Comments
EVALUATION

BasicTextUI.TextTransferHandler will now remember when one if its components is the source of the drag operation. If that component is also the target of the drag operation, it will check that the drop region is not inside the drag region. If it is, it will handle it nicely rather than clobbering the text.
###@###.### 2002-04-04
                                     
2002-04-04
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
hopper

FIXED IN:
hopper

INTEGRATED IN:
hopper

VERIFIED IN:
hopper-beta


                                     
2004-06-14



Hardware and Software, Engineered to Work Together