Java-打开网站
如何使用Java中的JButton打开网站?您可以使用来实现它Java-打开网站,java,url,action,Java,Url,Action,如何使用Java中的JButton打开网站?您可以使用来实现它 button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openWebpage("http://stackoverflow.com/help/how-to-ask"); } }); public void openWebpage(URI u
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openWebpage("http://stackoverflow.com/help/how-to-ask");
}
});
public void openWebpage(URI uri) {
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(uri);
} catch (Exception e) {
e.printStackTrace();
}
}
我没有得到你的评论。