Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javafx 2 如何使用Swing在JavaFX2.2中进行拖放操作?_Javafx 2 - Fatal编程技术网

Javafx 2 如何使用Swing在JavaFX2.2中进行拖放操作?

Javafx 2 如何使用Swing在JavaFX2.2中进行拖放操作?,javafx-2,Javafx 2,我对位于JPanel上的JFXPanel上的拖放事件有问题。当我将拖动消息推送到DragBoard时,应用程序的javaFX部分不再工作。我想这是关于摇摆运动的机械化,但我不确定。其他事件没有问题。这让我很困惑。这个问题有什么解决办法吗?提前谢谢 public class MyScene extends Scene { public MyScene(VBox vBoxMainLayout) { super(vBoxMainLayout); HBox h

我对位于JPanel上的JFXPanel上的拖放事件有问题。当我将拖动消息推送到DragBoard时,应用程序的javaFX部分不再工作。我想这是关于摇摆运动的机械化,但我不确定。其他事件没有问题。这让我很困惑。这个问题有什么解决办法吗?提前谢谢

public class MyScene extends Scene {

    public MyScene(VBox vBoxMainLayout) {
        super(vBoxMainLayout);

        HBox hBox = new HBox();
        hBox.setPrefSize(10000, 10000);
        hBox.setSpacing(40);

        Button buttonSource = new Button("Source");
        buttonSource.setMinSize(60, 30);

        buttonSource.setOnDragDetected(new EventHandler<MouseEvent>() {
            public void handle(MouseEvent event) {
                Dragboard db = startDragAndDrop(TransferMode.ANY);

                ClipboardContent content = new ClipboardContent();
                String message = "Drag operatation is done";
                content.putString(message);
                db.setContent(content);
                event.consume();
            }
        });

        buttonSource.setOnDragDone(new EventHandler<DragEvent>() {
            public void handle(DragEvent event) {

                event.consume();
            }
        });

        TextArea textAreaTarget = new TextArea();
        textAreaTarget.setMinSize(200, 500);

        hBox.getChildren().add(buttonSource);
        hBox.getChildren().add(textAreaTarget);

        vBoxMainLayout.getChildren().add(hBox);
    }

}

public class Main extends Application {

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

    @Override
    public void start(Stage stage) {
        VBox vBoxMainLayout = new VBox();
        MyScene myScene = new MyScene(vBoxMainLayout);

        JFrame frame = new JFrame();
        JFXPanel arg0 = new JFXPanel();
        arg0.setScene(myScene);
        frame.getContentPane().add(arg0);
        frame.setVisible(true);

    }
}
公共类MyScene扩展场景{
公共MyScene(VBox-vboxmain布局){
超级(VboxMain布局);
HBox HBox=新的HBox();
hBox.setPrefSize(10000,10000);
hBox.setspace(40);
按钮按钮源=新按钮(“源”);
buttonSource.setMinSize(60,30);
检测到buttonSource.setOnDragDetected(新的EventHandler(){
公共无效句柄(MouseeEvent事件){
Dragboard db=startDragAndDrop(TransferMode.ANY);
ClipboardContent=新的ClipboardContent();
字符串消息=“拖动操作完成”;
content.putString(消息);
db.setContent(content);
event.consume();
}
});
setOnDragDone(新的EventHandler(){
公共无效句柄(DrageEvent事件){
event.consume();
}
});
TextArea textAreaTarget=新建TextArea();
textAreaTarget.setMinSize(200500);
hBox.getChildren().add(按钮源);
hBox.getChildren().add(textAreaTarget);
vBoxMainLayout.getChildren().add(hBox);
}
}
公共类主扩展应用程序{
公共静态void main(字符串[]args){
发射(args);
}
@凌驾
公众假期开始(阶段){
VBox vBoxMainLayout=新的VBox();
MyScene MyScene=新MyScene(vBoxMainLayout);
JFrame=新JFrame();
JFXPanel arg0=新的JFXPanel();
arg0.setScene(myScene);
frame.getContentPane().add(arg0);
frame.setVisible(true);
}
}

这是JavaFX2.1中已知的死锁,被推到了2.2(这是我从oracle学到的),但我想它仍然没有解决。

谢谢。它看起来像一只虫子。你觉得怎么样?