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

NativeClipboard:if we sequentially copy the image to clipboard, paste, copy another image, paste we will get the first image.

    Details

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

      FX b41
      jdk 7
      windows xp

      Description

      To reproduce run following code.
      Open the http://download.oracle.com/javafx in browser.
      Right click on "JavaFX 2.0 Beta documentation" image -> copy.
      Press button "paste from clipboard" in sample application. You should see "JavaFX 2.0 Beta documentation" image.
      Right click on "Oracle" image in browser-> copy.
      Press button "paste from clipboard" in sample application. You should see "JavaFX 2.0 Beta documentation" image, but expected "Oracle" image.


      import java.io.File;
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.image.ImageView;
      import javafx.scene.input.Clipboard;
      import javafx.scene.input.DataFormat;
      import javafx.scene.layout.VBox;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;

      /**
       *
       * @author Andrey Nazarov
       */
      public class NativeClipboard2 extends Application {

          VBox contentSrc;
          VBox output;

          public static void main(String[] args) {
              launch(null);
          }

          @Override
          public void start(Stage stage) throws Exception {
              stage.setScene(new Scene(contentSrc = new VBox(20), 500, 500));

              final Button source;

              contentSrc.getChildren().addAll(source = new Button("Paste from clipboard"));
              contentSrc.getChildren().addAll(output = new VBox());

              source.setOnAction(new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(ActionEvent t) {
                      
                      Clipboard cb = Clipboard.getSystemClipboard();
                      getClipboardData(cb);

                  }
              });
              stage.show();

          }

          private void getClipboardData(Clipboard cb) {
              output.getChildren().clear();
              output.getChildren().add(new Text("Data formats:"));
              for (DataFormat type : cb.getContentTypes()) {
                  output.getChildren().add(new Text(type.toString()));
              }
              if (cb.hasString()) {
                  String str = cb.getString();
                  System.err.println("###STRING: " + str);
      // output.getChildren().add(new Label("PLAIN_TEXT:"+cb.getString()));
              }
              if (cb.hasUrl()) {
                  System.err.println("###URL: " + cb.getUrl());
      // output.getChildren().add(new Text("URL:"+cb.getUrl()));
              }
              if (cb.hasRtf()) {
                  System.err.println("###RTF: " + cb.getRtf());
      // output.getChildren().add(new Text("RTF:"+cb.getRtf()));
              }
              if (cb.hasHtml()) {
                  System.err.println("###HTML: " + cb.getHtml());
      // output.getChildren().add(new Text("HTML:"+cb.getHtml()));
              }
              if (cb.hasImage()) {
      // System.err.println("###Image: " + cb.getImage());
                  output.getChildren().add(new Text("Image:"));
                  output.getChildren().add(new ImageView(cb.getImage()));
              }
              if(cb.hasFiles()){
                  for(File f: cb.getFiles()){
                      System.err.println("##File: "+f);
                  }
              }
          }
      }

        Attachments

          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: