• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTML link on a JLabel or something

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know or has anyone created a class for putting an HTML a href link on a JLabel or button or something that will launch the default web browser and go to the specified link?
I tried using HTML inside the Label text and that looked like it was going to work, but I didn't add any click handling events, so by default it won't work. I am going to continue to work on this, but thought if anyone has already done it, they might help me out. If I figure it out in the mean time, I will post back here.
Thanks.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I found out a way to do this. I found a post from soneone here at the ranch from December of 2000. Here is the thread. I used that class that was posted. And then I created a LinkLabel class that looks like this:

It works in Windows. I haven't tried it in Linux. Hope this helps someone else.
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created something like this. it has lots of great features like highlighting the link in a color when hovered over and it works from an applet or an application. i plan on adding it to my open source java classes - if anyone ewants it let me know and i'll go ahead and post it for all to see/use.
it actually extends JPanel so that it fits in well anywhere in a gui.
brian
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic