151 lines
3.7 KiB
Java
Executable File
151 lines
3.7 KiB
Java
Executable File
package frame;
|
|
|
|
//~--- JDK imports ------------------------------------------------------------
|
|
|
|
import java.awt.*;
|
|
import java.awt.event.*;
|
|
|
|
import java.net.*;
|
|
|
|
import javax.swing.*;
|
|
|
|
public class JHyperLink extends JLabel implements MouseListener {
|
|
public Cursor Rollover_Cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
|
|
public Color LINK_COLOR;
|
|
public URI uri;
|
|
|
|
public JHyperLink() {}
|
|
|
|
public JHyperLink(String url) throws URISyntaxException {
|
|
super(url);
|
|
LINK_COLOR = Color.BLUE;
|
|
this.setForeground(LINK_COLOR);
|
|
uri = new URI(url);
|
|
this.addMouseListener(this);
|
|
}
|
|
|
|
public JHyperLink(String url, Color color) throws URISyntaxException {
|
|
super(url);
|
|
LINK_COLOR = color;
|
|
this.setForeground(LINK_COLOR);
|
|
uri = new URI(url);
|
|
this.addMouseListener(this);
|
|
}
|
|
|
|
public JHyperLink(String url, String title) throws URISyntaxException {
|
|
super(title);
|
|
this.LINK_COLOR = Color.BLUE;
|
|
this.setForeground(LINK_COLOR);
|
|
uri = new URI(url);
|
|
this.addMouseListener(this);
|
|
}
|
|
|
|
public JHyperLink(String url, String title, Color color) throws URISyntaxException {
|
|
super(title);
|
|
LINK_COLOR = color;
|
|
this.setForeground(LINK_COLOR);
|
|
uri = new URI(url);
|
|
this.addMouseListener(this);
|
|
}
|
|
|
|
@Override
|
|
public void setEnabled(boolean enabled) {
|
|
super.setEnabled(enabled);
|
|
|
|
if (enabled == true) {
|
|
MouseListener[] listeners = this.getMouseListeners();
|
|
|
|
try {
|
|
MouseListener listener = listeners[0];
|
|
} catch (Exception exc) {
|
|
this.addMouseListener(new JHyperLink());
|
|
}
|
|
}
|
|
|
|
if (enabled == false) {
|
|
MouseListener[] listeners = this.getMouseListeners();
|
|
|
|
for (int i = 0; ; i++) {
|
|
try {
|
|
MouseListener listener = listeners[i];
|
|
|
|
this.removeMouseListener(listener);
|
|
} catch (Exception exc) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setColor(Color color) {
|
|
this.LINK_COLOR = color;
|
|
super.setForeground(color);
|
|
}
|
|
|
|
public void setColor(int r, int g, int b) {
|
|
Color color = new Color(r, g, b);
|
|
|
|
this.setColor(color);
|
|
}
|
|
|
|
public void setColor(int r, int g, int b, int a) {
|
|
Color color = new Color(r, g, b, a);
|
|
|
|
this.setColor(color);
|
|
}
|
|
|
|
public Color getColor() {
|
|
return this.LINK_COLOR;
|
|
}
|
|
|
|
public void setURI(URI uri) {
|
|
this.uri = uri;
|
|
}
|
|
|
|
public void setURI(String uri) throws URISyntaxException {
|
|
this.uri = new URI(uri);
|
|
}
|
|
|
|
public URI getURI() {
|
|
return this.uri;
|
|
}
|
|
|
|
public void setText(String text, Color color) {
|
|
super.setText(text);
|
|
this.setColor(color);
|
|
}
|
|
|
|
public void setText(String text, int r, int g, int b) {
|
|
super.setText(text);
|
|
this.setColor(r, g, b);
|
|
}
|
|
|
|
public void setText(String text, int r, int g, int b, int a) {
|
|
super.setText(text);
|
|
this.setColor(r, g, b, a);
|
|
}
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
JHyperLink link = (JHyperLink) e.getComponent();
|
|
|
|
try {
|
|
Desktop.getDesktop().browse(link.uri);
|
|
} catch (java.io.IOException exc) {}
|
|
}
|
|
|
|
public void mousePressed(MouseEvent e) {}
|
|
|
|
public void mouseReleased(MouseEvent e) {}
|
|
|
|
public void mouseEntered(MouseEvent e) {
|
|
JHyperLink link = (JHyperLink) e.getComponent();
|
|
|
|
link.setCursor(link.Rollover_Cursor);
|
|
}
|
|
|
|
public void mouseExited(MouseEvent e) {}
|
|
}
|
|
|
|
|
|
//~ Formatted by Jindent --- http://www.jindent.com
|