Javafx SwingNode not working until window resized

I am trying to use SwingNode from JavaFX8 using this code. The problem is when the window appears. I can’t click the button until I resized the window. Moving does not work. I need to either maximize it or resize it with the mouse to make the button respond.

I understand that this may be a mistake, given that javafx8 is still in beta, but if it is not, do I need to do something to make this work without resizing the window in the first place?

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); } } 
+4
source share
1 answer

Your code is simplified, so this is most likely a bug in the beta.

+1
source

Source: https://habr.com/ru/post/1492210/


All Articles