JavaFX Freeze on Desktop.open(file), Desktop.browse(uri)

后端 未结 5 743
滥情空心
滥情空心 2020-12-09 16:13

I\'m running some code in Java on Ubuntu 12.04 LTS 64 Bit (with Gnome Shell), using Oracle JDK 1.8.0_05 via NetBeans8.0.

The following function works perfectly when

5条回答
  •  无人及你
    2020-12-09 16:59

    Encapsulate it on a System thread:

        final String url = "www.google.com";
        final Hyperlink hyperlink = new Hyperlink("Click me");
            hyperlink.setOnAction(event -> new Thread(() -> {
                try {
                    Desktop.getDesktop().browse(new URI(url));
                } catch (IOException | URISyntaxException e1) {
                    e1.printStackTrace();
                }
            }).start());
    

提交回复
热议问题