2015-12-10 91 views

回答

1

您可以使用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(); 
     } 
    }