-
Bug
-
Resolution: Fixed
-
P3
-
fx2.0
-
fx b41
jdk 7
windows xp
To reproduce run following code, copy some string to clipboard and press button "paste from clipboard", see console output.
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 NativeClipboard extends Application {
VBox contentSrc;
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"));
final VBox output;
contentSrc.getChildren().addAll(output = new VBox());
source.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
output.getChildren().clear();
Clipboard cb = Clipboard.getSystemClipboard();
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()));
}
}
});
stage.show();
}
}
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 NativeClipboard extends Application {
VBox contentSrc;
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"));
final VBox output;
contentSrc.getChildren().addAll(output = new VBox());
source.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
output.getChildren().clear();
Clipboard cb = Clipboard.getSystemClipboard();
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()));
}
}
});
stage.show();
}
}
- relates to
-
JDK-8120290 TextInputControl.paste() doesn't strip NULL characters from clipboard
-
- Closed
-