JDK-4712076 : Swing DnD: JTextArea caret disappears after dragging text
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2002-07-09
  • Updated: 2002-07-11
  • Resolved: 2002-07-11
Related Reports
Duplicate :  
Description

Name: dk106046			Date: 07/09/2002

Windows and Linux

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)

and

java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b13)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b13, mixed mode)
   
Testcase:

import java.awt.*;
import javax.swing.*;
public class DnDTest {
       public static void main(String [] args){
              new DnDTest();
       }
       public DnDTest(){
              JFrame f1 = new JFrame("Drag Source");
              JFrame f2 = new JFrame("Drop Target");
              JTextArea ta1 = new JTextArea("test");
              ta1.setDragEnabled(true);
              JTextArea ta2 = new JTextArea();
              
              f1.getContentPane().add(ta1);
              f2.getContentPane().add(ta2);
              f1.setSize(200,200);
              f1.setLocation(10,10);
              f2.setSize(200,200);
              f2.setLocation(230,10);

              f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              f1.show();
              f2.show();
              
       }
}

Select the text in the JTextArea named "Drag Source".
Please make sure that the selected text is highlighted and
the caret is blinking.

Drag and drop the selected text onto the other JTextArea named
"Drop Target" just at the moment that the caret disappears in
its blinking.

Move the focus to the Drag Source JTextArea.
The caret no longer appears in the Drag Source JTextArea.

The problem is timing related - you may need to try several
times to reproduce. I think the state of the blinking
caret is significant at the point you drag the text out of
the first window. To reproduce on Linux you need a window
manager set to "click to focus" mode.

======================================================================

Comments
WORK AROUND Name: dk106046 Date: 07/09/2002 You can move the focus to the root window (or another window) and move it back to the JTextArea. The caret then comes back. ======================================================================
24-08-2004

EVALUATION Name: agR10216 Date: 07/11/2002 With the built-in drop support, Swing text components respond to DnD dragovers by setting the Caret to visible and using it to display the potential insert location. When the drag exits the component, the Caret's visibility is restored. Unfortunately, since the Caret uses the same "visible" property to represent the usual meaning of visible as well as when it is in mid-flash, sometimes the Caret's visibility is restored incorrectly. [see http://java.sun.com/j2se/1.4/docs/guide/swing/1.4/dnd.html#KnownBugs, bug 4513720] This bug is duplicate of 4513720. ###@###.### 2002-07-10 ======================================================================
10-07-2002