aspose file tools*
The moose likes Java in General and the fly likes String with URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "String with URL" Watch "String with URL" New topic
Author

String with URL

Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
Hi all,

I have a String, for example:

String website = "http://www.coderanch.com"

I would like that, inside a SWT MessageBox (but in any other place of my application) by clicking on the String the browser opens and loads the website...is it possible?
Aditya Jha
Ranch Hand

Joined: Aug 25, 2003
Posts: 227

Not so sure about SWT, but in Swing I would do something like this:

Note that the exact command to run (in exec()) will be OS specific. Usually, we use OS-specific property-files to make the code portable.

I'm not sure if this automatically provides the functionality of mouse cursor turning into the 'Hand' cursor on moving over the link. But if not, take it as an exercise and try to implement it.

Hope this helps!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

I think that using java.awt.Desktop and it's browse method is a better solution than trusting on some OS specific technique.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String with URL