-
Bug
-
Resolution: Fixed
-
P3
-
fx2.0
-
java6
fx b42
windows 7
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();
}
}
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();
}
}
- relates to
-
JDK-8128389 Native clipboard/dragboard: passing data to native application doesn't work.
- Closed