Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with JavaFx #114

Open
FogiaFr opened this issue Jul 20, 2015 · 1 comment
Open

Integration with JavaFx #114

FogiaFr opened this issue Jul 20, 2015 · 1 comment

Comments

@FogiaFr
Copy link

FogiaFr commented Jul 20, 2015

I try to integrate an unfoldingmaps in JavaFx.
To do so, I use the SimpleMapApp example.
But I have either a blank screen or an exception (Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0).

Here is the example:

public class JavaFxIntegration extends Application {
    /** {@inheritDoc} */
    @Override
    public void start (Stage stage) {
        final SwingNode swingNode = new SwingNode();

        createSwingContent(swingNode);

        StackPane pane = new StackPane();
        pane.getChildren().add(swingNode);

        stage.setTitle("Unfoldingmaps in JavaFX");
        stage.setScene(new Scene(pane, 800, 600));
        stage.show();
    }

    /**
     * Integrate the unfoldingmaps in the swingNode.
     * @param swingNode parent node of the map.
     */
    private void createSwingContent(SwingNode swingNode) {
        SwingUtilities.invokeLater(() -> {
            SimpleMapApp map = new SimpleMapApp();
            map.init();

            JPanel panel = new JPanel();

            panel.setLayout(new BorderLayout());
            panel.add(map, BorderLayout.CENTER);
            panel.setPreferredSize(new Dimension(800, 600));
            panel.setBounds(0, 0, 800, 600);

            swingNode.setContent(panel);
        });
    }
}
@FogiaFr
Copy link
Author

FogiaFr commented Jul 20, 2015

I found a 'workaround' by opening a JFrame with a PApplet inside outside of the Javafx components.

But it could be interesting to have a PApplet in a JavaFx Stage so if you find out how to...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant