javafx SwingNode在调整窗口大小之前无法正常工作 [英] javafx SwingNode not working until window is resized
问题描述
我一直在使用此代码从JavaFX8尝试SwingNode。问题是当窗口出现时我无法单击按钮,直到我调整了窗口大小。移动它不起作用。我需要最大化它或用鼠标调整它以使按钮响应。
I have been trying the SwingNode from JavaFX8 using this code. The problem is when the window appears I can not click the button, until I have resized the window. Moving it does not work. I need to either maximize it or resize it with the mouse to get the button to respond.
我意识到这可能是一个错误,因为javafx8仍处于测试阶段,但如果不是这样的话,那么我需要做些什么才能让这个工作没有调整大小首先是窗口?
I realize this could be a bug given that javafx8 is still in beta, but if thats not the case is there something I need to do to make this work with out resizing the window first?
public class SwingNodeTest extends Application {
private SwingNode swingNode;
@Override
public void start(Stage stage) {
swingNode = new SwingNode();
createAndSetSwingContent();
StackPane pane = new StackPane();
pane.getChildren().add(swingNode);
stage.setScene(new Scene(pane, 100, 50));
stage.show();
}
private void createAndSetSwingContent() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
swingNode.setContent(new JButton("Click me!"));
}
});
}
public static void main(String[] args) {
Application.launch(args);
}
}
推荐答案
您的代码很简单,因此很可能是测试版中的错误。
Your code is simplistic, so it is most likely a bug in the beta.
这篇关于javafx SwingNode在调整窗口大小之前无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!