***URGENT HELP REQUIRED***Display a Hypertext link inside JTextField?

Hi guys.... Say my applet displays the text... " To go to this page click here" . ..... I want.. "click here" to be a be a hot link.. like in HTML .. one clicks on the text.. and the desired link is followd. How do I go about doing that in Applets?

Simply put : How do I go about displaying a Hypertext link inside a JLabel or JTextField?

[352 byte] By [arijit_dattaa] at [2007-10-3 4:06:31]
# 1
It's a simple and plain event handler issue, but, why don't you use HTML which should be lot simpler.
hiwaa at 2007-7-14 22:05:59 > top of Java-index,Desktop,Core GUI APIs...
# 2

Yes I know.. HTML is a lot more simpler.. The thing is.. this app is like a sort of auto run in a CD. When the CD gets popped in the exe starts running and a sort of sceen is displayed ( not HTML) where there are the "click me " links buttons etc. Now I have been tasked with making this app OS independent.. as i am a Java Programmer. Now I have to keep the app same.. so thats why i need the hint of how to creat a "click me link" ..

Yes even I thought of the event handling. but the problem is.. when say therd is this line "When you are too bored then click me"... And I only need to make "click me" as a hypelink .. so the obvious logical solution if you are take the event handling approach would be to place a JLabel and then a non editable JTextField.. HERE IS THE PROBLEM.. you will see a Field.. but in the original thing its just a plain text.. only the last portion is a hyperlink...

Thats why i need to know how to go about displaying Hyperlink in a TextField

arijit_dattaa at 2007-7-14 22:06:00 > top of Java-index,Desktop,Core GUI APIs...
# 3

If you use a JLabel with a mouselistener, you can put html in it and just underline and colour the bit you want to be a hyperlink - something like this...

"<html>This is html text that includes a <font color="Blue"> <u>hyperlink</u></font></html>"

The disadvantage of this approach is that the whole label is a hyperlink.

I guess another solution is to jam two fields with no borders next to each other - the second being the blue/underlined hyperlink with the mouseListener.

TimRyanNZa at 2007-7-14 22:06:00 > top of Java-index,Desktop,Core GUI APIs...
# 4

Hey Tim.. even I completely agree with you.. Now can u tell me.. how do i remove this border?

One more thing Tim.. We cant use JLabel .. it would turn out like the whole label as "<html>This is html text that includes a <font color="Blue"> <u>hyperlink</u></font></html>" .. Tags and all.. so no point.

You have a better idea?

arijit_dattaa at 2007-7-14 22:06:00 > top of Java-index,Desktop,Core GUI APIs...
# 5
> How do I go about displaying a Hypertext link inside a JLabel or JTextField? You don't, you use a JEditorPane.
camickra at 2007-7-14 22:06:00 > top of Java-index,Desktop,Core GUI APIs...
# 6

> it would

> turn out like the whole label as "<html>This is html

> text that includes a <font color="Blue">

> <u>hyperlink</u></font></html>" .. Tags and all.. so

> no point.

No it wouldn't. JLabels render HTML correctly. JTextfields don't because they are updateable, but JLabels render it fine!

TimRyanNZa at 2007-7-14 22:06:00 > top of Java-index,Desktop,Core GUI APIs...
# 7

Strange, I think I did something like "<html>Text <b>in bold</b></html>" on a table -> JLabel.

So you couldn't do

"<html>Whatever text you like <[html link tag] Whatever link text you like [html ref tag]http://yourlink.xy/...</[html link tag]></html>"

or maybe even just

"Whatever text you like <html><[html link tag] Whatever link text you like [html ref tag]http://yourlink.xy/...</[html link tag]></html>"?

agerard2a at 2007-7-14 22:06:00 > top of Java-index,Desktop,Core GUI APIs...
# 8
No you can't get it to do the actual link automatically just by adding html to the JLabel - it ain't that clever!
TimRyanNZa at 2007-7-14 22:06:00 > top of Java-index,Desktop,Core GUI APIs...