Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4168121

Ctrl C fails to copy data to JVM's clipboard

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.2.0, 1.2.1, 1.2.2
    • client-libs
    • x86, sparc
    • solaris_2.6, windows_95, windows_nt

      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)
      ======================================================================

            ibdsunw Ibd Ibd (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: