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

Setting clipboard twice loses ownership

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Description



      Name: diC59631 Date: 10/03/97


      1.
      1.1 javac SetClipboardTest.java
      1.2 java SetClipboard

      2.

      import java.awt.*;
      import java.awt.datatransfer.*;

      class SetClipboardTest2 extends Thread implements ClipboardOwner{
          String content;

          
          public void lostOwnership(Clipboard clipboard, Transferable contents) {
      // okay......
      System.out.println("-->content \""+contents+"\" in clipboard lost ownership...");
          }

          /**
           * Set the clipboard with the given string.
           */
          public SetClipboardTest2(String content) {
      this.content = content;
          }

          /**
           * Put something on the clipboard
           */
          public void run() {
      Toolkit toolkit = Toolkit.getDefaultToolkit();
      Clipboard cb = toolkit.getSystemClipboard();
      StringSelection currentClip = new StringSelection(content);

      System.out.print("[1] Setting clipboard content first time ... ");
      cb.setContents(currentClip, this);
      System.out.println("done!");

      System.out.print("[2] Setting clipboard content second time ... ");
      cb.setContents(currentClip, this);
      System.out.println("done!");

      System.exit(0);
          }

          public static void main(String arg[]) {
      System.out.println("-=[ CLIPBOARD TEST ]=-");
      new Thread(new SetClipboardTest2("test")).start();
          }
      }



      3.

      -=[ CLIPBOARD TEST ]=-
      [1] Setting clipboard content first time ... done!
      [2] Setting clipboard content second time ... -->content "java.awt.datatransfer.StringSelection@1dce088c" in clipboard lost ownership...
      done!

      4.

      none.

      5.

      none.
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rramsunw Ranganathan Ram (Inactive)
              Reporter:
              dindrigo Daniel Indrigo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: