JDK-4168121 : Ctrl C fails to copy data to JVM's clipboard
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.2.0,1.2.1,1.2.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6,windows_95,windows_nt
  • CPU: x86,sparc
  • Submitted: 1998-08-21
  • Updated: 2001-04-17
  • Resolved: 2001-04-17
Related Reports
Duplicate :  
Relates :  
Description
If you copy data into the clipboard (using the clipboard API's),
select text in a text field and hit Ctrl-C the selected text is not copied
into the JVM's clipboard.

	Run the attached test program
	 * click over the drawn text ("this is a test")
	    (this places the text in the clipboard). To verify,
	    goto some other window and hit the paste key. You should
	    see "this is a test".
	 * type data in to the text field (above the drawn text)
	 * select some or all of the data in the text field
         * hit Ctrl-C
	 * now hit the paste key or Ctrl-V repeatedly
	 * instead of seeing what was selected before pasted over and over again,
	   I see "this is a test" pasted !! If I go over to another terminal 
	   window and hit paste, what was selected in the test program is
	   pasted properly.
	   It looks like the JVM's system clipboard is not updated properly.


Name: skT88420			Date: 01/27/2000


java version "1.2.2"
Classic VM (build JDK-1.2.2-001, native threads, symcjit)

It is not possible to access files copied to the system clipboard via
java.awt.datatransfer. Everytime I 'copy' files in Windows Explorer (either
by CTRL + C or menu or toolbar) and then run the Java application below, the
returned Transferable object is null.

Is this a bug or is it 'planned functionality'? If the latter, then why have Sun
gone to so much trouble to implement platform independent drag'n'drop but not
copy/paste!?!?

  To reproduce the problem, do the following:
1. Start Windows Explorer in Windows NT 4.0
2. Select some files
3. Copy the files by presing CTRL + C or the toolbar copy button or selecting
copy from the menu
4. Run the Java application below
5. The application should print out "Contents of clipboard are equal to NULL"

That is, Java cannot access 'copied' files in the system clipboard via the
java.awt.datatransfer classes and interfaces.



/*
 * TestingCopyCutPaste.java
 *
 * Created on 27. januar 2000, 11:34
 */
 
import java.awt.*;
import java.io.*;
import java.awt.datatransfer.*;

/**
 *
 * @author  XAD0101
 * @version
 */
public class TestingCopyCutPaste extends Object implements ClipboardOwner
{
  /** Creates new TestingCopyCutPaste */
  public TestingCopyCutPaste()
  {
  }
  
  /**
  * @param args the command line arguments
  */
  public static void main (String args[])
  {
    Toolkit tk = Toolkit.getDefaultToolkit();
    Clipboard cb = tk.getSystemClipboard();
    Transferable trans = cb.getContents(null);
    if (trans != null)
    {
      DataFlavor[] df = trans.getTransferDataFlavors();
      for (int i = 0; i < df.length; i++)
      {
        System.out.println("DataFlavor " + i + " is " + df[i].toString());
      }
    }
    else
    {
      System.out.println("Contents of clipboard are equal to NULL");
    }
  }
  public void lostOwnership(Clipboard clipboard, Transferable contents)
  {
    System.out.println("Lost ownership of " + contents.toString() + " from
clipboard " + clipboard.toString());
  }
}
(Review ID: 100409)
======================================================================

Comments
PUBLIC COMMENTS Ctrl C fails to copy data to JVM's clipboard
10-06-2004

EVALUATION The description reports two separate bugs: CTRL-C in TextFields and clipboard file lists. CTRL-C in TextFields: Bug appears to be resolved in merlin build 25 on Windows. On Solaris, when I press the 'Copy' key, I see the following exception: Exception in thread "AWT-Motif" java.lang.NullPointerException at sun.awt.motif.X11Selection.lostSelectionOwnership(X11Selection.java:154) at sun.awt.motif.MToolkit.run(Native Method) at java.lang.Thread.run(Thread.java:488) Clipboard file lists: This was fixed by the data transfer unification. Resolved in merlin build 25. Keeping this bug open so we can fix the NPE. david.mendenhall@eng 2000-08-02 Reproducible with 12Dec2000 AWT workspace. david.mendenhall@east 2000-12-13 The bug report for this bug describes several different problems. Two of them - proper update of JVM's clipboard and transfer of file lists via clipboard are reported to be fixed. Indeed, they are not reproducible with the current workspace. The third problem you mentioned - NPE on Solaris - also isn't reproducible, because it was fixed by Danila along with 4388802. When I backed out a part of this fix in X11Selection.java, NPE started to pop out (when I was pressing the COPY key repeatedly). So I suggest to close 4168121 as a duplicate of 4289735 (Unification of Clipboard & DnD Data Transfer). ###@###.### 2001-4-17
17-04-2001