java.lang.Object
org.monte.media.swing.JLabelHyperlinkHandler
JLabelHyperlinkHandler makes HTML hyperlinks in a JLabel
clickable.
You can add an action listener to this handler to perform the desired action.
The command contains the content of the href attribute in the hyperlink.
Example:
File f=new File(System.getProperty("user.home"));
JLabel l=new JLabel("<html>Click this <a href="\""+
f.toURI();+
"\"">link</a> to open your home folder.");
new JLabelHyperlinkHandler(l, new ActionListener() {
public void ActionPerformed(ActionEvent evt) {
try {
File f = new File(new URI(e.getActionCommand()));
Desktop.getDesktop().open(f);
} catch (URISyntaxException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
});
- Author:
- Werner Randelshofer
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
JLabelHyperlinkHandler
public JLabelHyperlinkHandler() -
JLabelHyperlinkHandler
-
-
Method Details
-
setLabel
-
getLabel
-
addActionListener
-
removeActionListener
-