(Hmpfff... Managers with design ideas...)
TIA...
--
Dag.
http://www.google.com/search?q=JLinkLabel
--
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
> Can I us a JLabel or something else to make something look
> like a html hyperlink (underline, hand cursor...),
> and trigger an actionEvent like a JButton?
You're in luck. Just having come from a c.l.j.? convo.
about links, I writ this..
<sscce>
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class LinkLabel extends Label implements MouseListener {
URL url;
final Color normal = Color.blue;
final Color hover = Color.red;
final Color active = Color.magenta;
Color mouseOutDefault;
public LinkLabel(String text, URL url) {
super(text);
this.url = url;
this.addMouseListener(this);
setForeground( normal );
mouseOutDefault = normal;
}
public void paint(Graphics g) {
super.paint(g);
g.drawLine( 2,
getHeight()-5,
getPreferredSize().width-12,
getHeight()-5 );
}
public void mouseReleased(MouseEvent me) {}
public void mousePressed(MouseEvent me) {
mouseOutDefault = active;
}
public void mouseExited(MouseEvent me) {
setForeground( mouseOutDefault );
System.out.println( "Clear 'status bar'" );
}
public void mouseEntered(MouseEvent me) {
setForeground( hover );
System.out.println( "Display '" + url + "' in 'status bar'" );
}
public void mouseClicked(MouseEvent me) {
setForeground( active );
mouseOutDefault = active;
System.out.println( "Open '" + url + "' now!" );
}
public static void main(String[] args)
throws MalformedURLException {
Frame f = new Frame("Link Label Demo");
f.setLayout(new GridLayout(0,1));
f.add( new LinkLabel("PhySci Web & IT help",
new URL("http://www.physci.org/codes/")) );
f.add( new LinkLabel("Sun Microsystems - Developer Network",
new URL("http://java.sun.com")) );
f.add( new LinkLabel("Some Other Site",
new URL("http://www.someothersite.com")) );
f.pack();
f.setVisible(true);
}
}
</sscce>
> (Hmpfff... Managers with design ideas...)
Ya' get that. ;-)
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
You're da' man, Andrew!
Thank you.
--
Dag.
> You're da' man, Andrew!
>
> Thank you.
You're welcome.
[ But I suspect JLinkLabel as linked by Thomas might be the best way to
go. The author probably wrote some design for it & spent more than 20
minutes coding, and 3 testing, it. I was almost going to do a search
myself but decided I actually wanted to see if my (simple) approach
would work. ;-) ]