通过java中的按钮启动网站

通过java中的按钮启动网站,java,Java,我正在开发一个软件,用户可以通过点击java按钮访问任何网站 JButton button1 = new JButton("Click Me"); button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent myEvent) { // Here clicking this method will open a website open("www.myrequired

我正在开发一个软件,用户可以通过点击java按钮访问任何网站

JButton button1 = new JButton("Click Me");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent myEvent) {
    // Here clicking this method will open a website
   open("www.myrequiredWesite.com");
}
}))

如何从上面的java源代码调用默认浏览器,以便默认浏览器将在java图形用户界面中单击按钮打开特定站点

public static void openPage(URI uri) {
    Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
    if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
        try {
            desktop.browse(uri);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

public static void openPage(URL url) {
    try {
        openPage(url.toURI());
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
}

注意使用
java.net
在当前web浏览器中使用桌面对象

?可能重复