码迷,mamicode.com
首页 > 编程语言 > 详细

javafx clipboard

时间:2015-08-11 14:06:22      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

 public class EffectTest extends Application {
public static void main(String[] args) {
    launch(args);
  }

  @Override
  public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Button Sample");
    stage.setWidth(300);
    stage.setHeight(190);

    VBox vbox = new VBox();
    vbox.setLayoutX(20);
    vbox.setLayoutY(20);

    final Button button1 = new Button("Accept");
 

    button1.addEventHandler(MouseEvent.MOUSE_CLICKED,
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent e) {
            
              
    // DataFormat fmt = new DataFormat("text/foo", "text/bar");
    Clipboard clipboard = Clipboard.getSystemClipboard();
    // get data from Clipboard
    System.out.println(" from System.Clipboard :"+clipboard.getString());
    
    ClipboardContent content = new ClipboardContent();
    // put data to system clipboard
    content.putString(" test clipboard" );
    
    clipboard.setContent(content);
              
              
          }
        });

  

    vbox.getChildren().add(button1);
    vbox.setSpacing(10);
    ((Group) scene.getRoot()).getChildren().add(vbox);

    stage.setScene(scene);
    stage.show();
  }
    
}

 

javafx clipboard

标签:

原文地址:http://www.cnblogs.com/rojas/p/4720753.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!