DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
JLabel Link: Open Browser Form Swing GUI By Clicking On Link
// Opens a browser on a specific site when clicking on the JLabel
link = new JLabel(" Click here to find the PUID \n");
link.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
link.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 0) {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
try {
URI uri = new URI("http://www.nationalarchives.gov.uk/PRONOM/Format/proFormatSearch.aspx?status=new");
desktop.browse(uri);
} catch (IOException ex) {
// do nothing
} catch (URISyntaxException ex) {
//do nothing
}
} else {
//do nothing
}
}
}
});





