Home arrow static arrow Java Programming [Archive] - HyperlinkListener invalid URL
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - HyperlinkListener invalid URL
This topic has 4 replies on 1 page.

Posts:87
Registered: 8/5/02
HyperlinkListener invalid URL  
Jul 12, 2004 8:08 AM



 
I am writing a chat client and want to allow a user to type in a URL that will change to a link and be clickable. I have it all implemented, but I noticed that if there is no "http://" preceding the address, the URL is null and cannot be opened.

Is there a way around this? For instance, if a user types in "www.google.com", the URL will be null and will not be able to be opened.
 

Posts:31,095
Registered: 4/30/99
Re: HyperlinkListener invalid URL  
Jul 12, 2004 8:10 AM (reply 1 of 4)



 
Prepend "http://" before interpreting it as a URL if it doesn't already have a protocol part?
 

Posts:87
Registered: 8/5/02
Re: HyperlinkListener invalid URL  
Jul 12, 2004 8:14 AM (reply 2 of 4)



 
Sorry, I posted too soon. A workaround would be to grab the description of the event, which will give you the text of the link. I can then check to see if http:// is there, if not, then append it.
 

Posts:87
Registered: 8/5/02
Re: HyperlinkListener invalid URL  
Jul 12, 2004 8:14 AM (reply 3 of 4)



 
Sorry, I posted too soon. A workaround would be to grab the description of the event, which will give you the text of the link. I can then check to see if http:// is there, if not, then append it.
 

Posts:87
Registered: 8/5/02
Re: HyperlinkListener invalid URL  
Jul 12, 2004 8:15 AM (reply 4 of 4)



 
Sorry for the double post - this thing said there was an error :)

The reason why I didn't try the prepending first was because I thought the HyperlinkEvent was just a null value - oversight on my part. Thanks for your response.
 
This topic has 4 replies on 1 page.