This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use html for LABEL

 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I am using Swing for some gui. I have to open some html page for which i am using JLabel with the following html tag


I was thinking that it'd open html file in browser when i click on label (without implementing any action listener). But it is not. Can somebody tell me what the wrong i am doing?
 
Joe Ess
Bartender
Posts: 9256
9
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML support in most Swing components is provided simply to make text formatting easy. It will not duplicate the functionality of a web browser (i.e. clicking on an anchor tag taking you to another page). See here for the Java Tutorial chapter on HTML in Swing.
You either need to implement a listener to handle the mouse click or use a component like EditorPane which can more fully parse and render HTML.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic