JDK-4513715 : JTextComponent: DnD from and to same region clobbers selection & pastes nothing
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2001-10-11
  • Updated: 2002-06-13
  • Resolved: 2002-04-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
1.4.1 hopperFixed
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
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: hopper FIXED IN: hopper INTEGRATED IN: hopper VERIFIED IN: hopper-beta
2004-06-14

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