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

Clipboard/dragboard: serialization of custom dataformats doesn't work for strings between two fx applications.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.0.2
    • Component/s: javafx
    • Environment:

      java6
      fx b42
      windows 7

      Description

      To reproduce run following code twice. In the first application press "copy to clipboard" and in the second press "paste from clipboard".



      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.input.Clipboard;
      import javafx.scene.input.ClipboardContent;
      import javafx.scene.input.DataFormat;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class ClipboardSample extends Application {

          public static void main(String[] args) {
              launch(args);
          }
          final static DataFormat DF = new DataFormat("custom.string");
          private Parent getContent() {
              VBox list = new VBox(10);
              Button but = new Button("Copy to clipboard");
              but.setOnAction(new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(ActionEvent t) {
                      Clipboard cb = Clipboard.getSystemClipboard();
                      ClipboardContent cc = new ClipboardContent();
                      cc.put(DF, "Hello world!!!");
                      cb.setContent(cc);
                  }
              });

              list.getChildren().add(but);
              Button but1 = new Button("Paste from clipboard");
              but1.setOnAction(new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(ActionEvent t) {
                      Clipboard cb = Clipboard.getSystemClipboard();
                      System.err.println("###Custom df: " + cb.getContent(DF));
                      System.err.println("###Custom df: " +(String) cb.getContent(DF));

                  }
              });

              list.getChildren().add(but1);
              return list;
          }

          public void start(Stage stage) {

              stage.setX(100);
              stage.setY(100);
              stage.setWidth(200);
              stage.setHeight(200);
              Scene scene = new Scene(getContent());
              stage.setScene(scene);
              stage.show();
          }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psafrata Pavel Ĺ afrata
                Reporter:
                anazarov Andrey Nazarov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: