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

Can't paste from external buffer after you copied something

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1.6
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      solaris_2.6

      Description



      Name: keC81026 Date: 05/14/99

      Proplems with Copy/Paste under Solaris

      to reproduce
              1. compile and run MyTextArea.java
              2. Copy comething ( from xterm ) to the internal buffer
              3. Press "Paste" button, note that text in console is the same
              that you copied
              4. Press "Copy" button, "Paste" button and note that text in
              console is "Foo text"
              5. Now, repeat 2,3 steps and note, that the text in the
              console is "Foo text"

      ====================== MyTextArea.java ===================
      import java.awt.Frame;
      import java.awt.Button;
      import java.awt.TextArea;
      import java.awt.BorderLayout;
      import java.awt.datatransfer.*;
      import java.awt.event.ActionListener;
      import java.awt.event.ActionEvent;
      import java.awt.Toolkit;


      class MyTextArea implements ActionListener {

          public static Button b = new Button("Paste");
          public static Button b2 = new Button("Copy");

          public MyTextArea() {
          };

          public static void main( String argv[] ) {
              Frame f = new Frame("Test Frame");
              f.setLayout( new BorderLayout() );
              f.add("North",b);
              f.add("South",b2);
              b.addActionListener( new MyTextArea() );
              b2.addActionListener( new MyTextArea() );
              f.pack();
              f.show();
          }

          public void actionPerformed( ActionEvent e ) {
              if( ((Button)(e.getSource())).getLabel() == "Paste" ) {
                      Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                      try {
                           Transferable data = clipboard.getContents(this);
                           String text = (String) data.getTransferData(DataFlavor.stringFlavor);
                           System.out.println(text);
                      } catch (Exception ex) {
                      }
              } else {
                  String text = "Foo text";
                  if (text != null) {
                      StringSelection stringSel = new StringSelection(text);
                      Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSel, null);
                     }
              }
          }


      }
      ================================================================================



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

        Attachments

          Activity

            People

            Assignee:
            agerasimsunw Alexander Gerasimov (Inactive)
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: