1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-11 11:55:03 -05:00
filebot/source/net/sourceforge/tuned/ui/HyperlinkLabel.java
Reinhard Pointner adb4d68055 * Lazy XPath evaluation for EpisodeList/Subtitle Clients
* AbstractSearchPanel (used in SubtitlePanel only so far)
* started using GlazedLists
* replaced searchtextfield with customized combobox (will be used for completion in the future)
* renamed FileFormat to FileUtil and move to tuned
* removed ESC shortcut
2008-06-21 19:24:18 +00:00

59 lines
1.2 KiB
Java

package net.sourceforge.tuned.ui;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.SystemColor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;
public class HyperlinkLabel extends JLabel {
private final URI link;
private final Color defaultColor;
public HyperlinkLabel(String label, URI link) {
super(label);
this.link = link;
defaultColor = getForeground();
addMouseListener(linker);
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
private MouseListener linker = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent event) {
try {
Desktop.getDesktop().browse(link);
} catch (Exception e) {
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
}
}
@Override
public void mouseEntered(MouseEvent e) {
setForeground(SystemColor.textHighlight);
}
@Override
public void mouseExited(MouseEvent e) {
setForeground(defaultColor);
}
};
}