-7
如何在Java中使用JButton打开网站?Java - 打开网站
如何在Java中使用JButton打开网站?Java - 打开网站
您可以使用Desktop API#browse来实现它。
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();
}
}
不客气! – redFIVE
哇,太好了。 –
我没有收到您的评论。 –