| 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: 19216
|
|
|
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
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: String with URL
|
|
|