Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding a HyperLink to a Table Cell

 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Please can someone tell me how to add a HyperLink to a Table Cell? I tried to add a link using the HTML tags with <A href....> but this does not help as the renderer does not respond to click events.
Thanks in Advance,
 
Ben Zung
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are talking about JTable, I'd add a mouse listener on the cell and fire up a Process to start the default browser with the url. Never heard of <a> tag working with JTable directly. Rendering table cell and set its editor to be some kind of JEditorPane could be a way out.

Good luck.
[ March 14, 2006: Message edited by: Ben Zung ]
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the inputs Ben. I will try out these.
 
Palash Ray
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is something called the HyperlinkListener. U need to imoplement this to listen to the hyperlink clicks.

Look at: j2sdk1.4.x\demo\jfc\SwingSet2\src\HtmlDemo.java

Here is the essence:

new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (e instanceof HTMLFrameHyperlinkEvent) {
((HTMLDocument)html.getDocument()).processHTMLFrameHyperlinkEvent(
(HTMLFrameHyperlinkEvent)e);
} else {
try {
html.setPage(e.getURL());
} catch (IOException ioe) {
System.out.println("IOE: " + ioe);
}
}
}
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!