Hyperlink to URL

It's a long time being blogging. Actually not done anything new from long time :). Here is one simple concept which some guys asked me. We have provided hyperlink API in JavaFX 1.2 but some of us struggled to open a URL using hyperlink API.

Hmm, 2 ways to do it actually.

 No1 : Use the Desktop API of JDK6. It's simple to use. One example is here.

So, very basic code will go like this :


package sample2; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.control.\*; import java.net.\*; Stage {     title: "HyperLink to URL"     width: 240     height: 320     scene: Scene {         content: [             Hyperlink{                 translateY: 160                 translateX: 40                 width: 150                 text: bind "Visit javafx Samples! "                 action: function():Void{                     java.awt.Desktop.getDesktop().browse(new URI("http://javafx.com/samples"));                 }             }         ]     } }

So, 2 things for running this code. First,Desktop API has been added in JDK6, so this code won't run on JDK5. Second, Add rt.jar(rt.jar of JDK6) file in the Libraries if you are using Netbeans

No2 : For only JavaFX code, we can use AppletStageExtension like this :

package sample1;

import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.control.Hyperlink; import javafx.stage.AppletStageExtension; Stage {     title: "Hyperlink to URL"     width: 250     height: 80     scene: Scene {         content: [             Hyperlink {                 text: "JavaFX Samples !"                 action: function() {                        AppletStageExtension.showDocument("http://javafx.com/samples");                 }             }         ]     } }

In this case, you cant send hyperlink from Desktop Application, but it will work fine for applet or Browser application. So, best is to use this and then use our normal funda : if {__PROFILE__}" != "browser") --> use the Desktop API code. What you say :).

Please let me know if there is any issue in the code ! Or also if there is any better way to do this.


Nice article :O) , rather on \*nx machine i was using sed with an RE to get the URL.

Posted by hemanth.hm on July 26, 2009 at 09:20 AM IST #

:D Thank you. your is complicated one :)

Posted by Vaibhav on July 26, 2009 at 12:25 PM IST #

It seems that java.awt.Desktop.getDesktop() method will not work on Mac with JDK 1.5.

I have created the issue RT-5222 to have a unified way for a URL opening in a browser.


Posted by Alexandr on July 27, 2009 at 07:38 AM IST #

Nice. I guess in place of bug you can move it into feature request.
Because this apparently need to go down to JDK not on JavaFX. Underlying JDK dont provide any such feature in 1.5. We need to move on JDK6 :D.

Posted by Vaibhav Choudhary on July 27, 2009 at 07:49 AM IST #

Good tip. Also you can try the more complex but flexible code at

Posted by Winston Prakash on July 28, 2009 at 06:44 PM IST #

ah i see. yes, this also sounds good :). Thanks for sharing !

Posted by Vaibhav on July 29, 2009 at 01:29 PM IST #


Thanks for posting this. Per your suggestion, I had to add %JAVA_HOME%/Java/jre6/lib/rt.jar to make this work. "rt.jar" is already present in the Java platform and is visible in Netbeans via Tools --> Java Platforms. So, why does one have to add "rt.jar" to the libraries of this particular project again ?.


Posted by rk tumuluri on September 13, 2009 at 02:59 AM IST #

I found your post really interesting. I found Internet marketing a really a great way of promoting a website. I found good results when I started internet marketing my website.

Posted by Jeff Paul Shortcuts on October 05, 2009 at 06:01 PM IST #

thank you

Posted by Vaibhav Choudhary on October 06, 2009 at 03:40 AM IST #

Really Nice Post. More and more businesses are indulge with online presence, it is costly if you find a wrong company to do your job

Posted by Internet Business Review on October 10, 2009 at 06:08 PM IST #

Its very intresting and Informative stuff. Women finds it difficult to manage their cost, save $1 a day and you can see the difference it makes

Posted by Wealthy Women Debts on November 19, 2009 at 06:27 PM IST #

[urltp://www.kissnfl.com/nfl-jerseys-c-631.html][b]authentic football jerseys[/b][/url]
[url=http://www.kissnfl.com][b]authentic jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]authentic nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]authentic nhl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]buy nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]cheap football jerseys[/b][/url]
[url=http://www.kissnfl.com][b]cheap jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]cheap nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]cheap nhl jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]chicago blackhawks nhl[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]custom football jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]custom nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]customized nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]discount nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]discount nhl jerseys[/b][/url]
[url=http://www.kissnfl.com][b]hockey jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl authentic[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl football jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl jersey[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl memorabilia[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl replica jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl store[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl stores[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl youth[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl apparel[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl hockey[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl hockey apparel[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl hockey jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl jersey[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl new jersey devils[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl player[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl shop[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl store[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl team[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl teams[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl vintage[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]penguins jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]red wings nhl[/b][/url]
[url=http://www.kissnlf.com][b]replica jerseys[/b][/url]
[url=http://www.kissnfl.com/][b]saints jerseys[/b][/url]
[url=http://www.kissnfl.com/][b]sports apparel[/b][/url]
[url=http://www.kissnfl.com/][b]sports jerseys[/b][/url]
[url=http://www.kissnfl.com/][b]steeler jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]stitched nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/][b]team jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]vintage nhl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]wholesale nfl[/b][/url]
[url=http://www.kissnfl.com][b]youth jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]youth nfl jerseys[/b][/url]

Posted by kissnfl on January 14, 2010 at 02:05 AM IST #

[url=http://www.vip-boots.com/]timberland logo[/url]
[url=http://www.vip-boots.com/]timberland company[/url]
[url=http://www.vip-boots.com/]Timberland Womens Shoes[/url]
[url=http://www.vip-boots.com/]timberland official site[/url]
[url=http://www.vip-boots.com/]official timberland[/url]
[url=http://www.vip-boots.com/]timberland official website[/url]
[url=http://www.vip-boots.com/]timberland classic[/url]
[url=http://www.vip-boots.com/]timberland outdoor[/url]
[url=http://www.vip-boots.com/]timberland on line[/url]
[url=http://www.vip-boots.com/]timberland history[/url]
[url=http://www.vip-boots.com/]timberland usa[/url]
[url=http://www.vip-boots.com/]timberland euro hiker[/url]
[url=http://www.vip-boots.com/]timberland mukluk[/url]
[url=http://www.vip-boots.com/]timberland online store[/url]
[url=http://www.vip-boots.com/]timberland site[/url]
[url=http://www.vip-boots.com/]pink timberland[/url]
[url=http://www.vip-boots.com/]timberland splitrock[/url]
[url=http://www.vip-boots.com/]timberland nellie[/url]
[url=http://www.vip-boots.com/]timberland shoes[/url]
[url=http://www.vip-boots.com/mens-chukka-boots-c-15.html]timberland chukka[/url]
[url=http://www.vip-boots.com/mens-rolltop-boots-c-12.html]timberland roll top[/url]
[url=http://www.vip-boots.com/]Timberland knee high boots[/url]
[url=http://www.vip-boots.com/]work boot Timberland[/url]
[url=http://www.vip-boots.com/]timberland boots for women[/url]
[url=http://www.vip-boots.com/]timberland boots men[/url]
[url=http://www.vip-boots.com/]timberland boots for men[/url]
[url=http://www.vip-boots.com/]Timberland Hiking Boot[/url]
[url=http://www.vip-boots.com/]timberland womens boots[/url]
[url=http://www.vip-boots.com/]timberland work boots[/url]
[url=http://www.vip-boots.com/]timberland mens boots[/url]
[url=http://www.vip-boots.com/kids-timberland-boots-c-14.html]timberland kids boots[/url]

Posted by vip-boots on January 14, 2010 at 02:06 AM IST #

It's a <a href=http://www.mynikeairmax.com/>Air Max</a>Friday, but these students aren't in school. They're at<a href=http://www.mynikeairmax.com/>Air Max 95</a> a youth center where the U.S. Armyis keeping <a href=http://www.mynikeairmax.com/>Air Max90</a>soldiers' children engaged and learning on the 17 Fridays this school year the state of Hawaii has closed public schools to narrow a budget deficit.

Posted by nike air max on February 01, 2010 at 04:42 AM IST #

http://www.nikelink.com nike air max right?

Posted by nike air max on March 05, 2010 at 12:56 AM IST #

Christian Louboutin http://www.christianlouboutinmarts.com
Christian Louboutin Shoes http://www.christianlouboutinmarts.com
christian louboutin sale http://www.christianlouboutinmarts.com
Christian Louboutin Boots http://www.christianlouboutinmarts.com
Christian Louboutin Pumps http://www.christianlouboutinmarts.com
Christian Louboutin Sandals http://www.christianlouboutinmarts.com

tiffany wholesale http://www.toptiffanylinks.com
tiffany stores http://www.toptiffanylinks.com
replica tiffany http://www.toptiffanylinks.com
cheap jewelry http://www.toptiffanylinks.com
replica tiffany retail http://www.toptiffanylinks.com
pandora jewelry http://www.toptiffanylinks.com
replica pandora jewelry http://www.toptiffanylinks.com

ed hardy http://www.ed-onlineshop.com
ed hardy clothing http://www.ed-onlineshop.com
ed hardy t shirt http://www.ed-onlineshop.com
ed hardy jeans http://www.ed-onlineshop.com
wholesale ed hardy http://www.ed-onlineshop.com
ed hardy shirt http://www.ed-onlineshop.com
ed hardy boots http://www.ed-onlineshop.com

ed hardy swimwear http://www.edhardydream.com
ed hardy clothing http://www.edhardydream.com
ed hardy clothes http://www.edhardydream.com
ed hardy t shirts http://www.edhardydream.com
ed hardy jeans http://www.edhardydream.com
ed hardy sunglasses http://www.edhardydream.com
ed hardy sunglass http://www.edhardydream.com

nike shox http://www.nikesshox.com
ghd http://www.ghddhair.com
mbt http://www.us-mbt.com

Posted by china wholesale on March 07, 2010 at 01:47 AM IST #

I would like to introduce a very good company, electronic products dealer.
I have bought some products from company,the price was very cheap,and the products are very good quality!They accept paypal, credit card transactions,bank transfers,and more.Just have a look at this web page : http://www.nike-airyeezy.com
I am sure you will could save a lot of money!
Best regards!
web: http://www.victoriawear.com

Posted by wwwnice on March 09, 2010 at 06:07 AM IST #

Although it's a bit complicated, as it was already mentioned in a comment above, it's still informative and helpful indeed. I've tried to accomplish everything step by step and for now it looks that it's OK when running the code on JDK6.

Posted by tiffany on May 11, 2010 at 01:10 PM IST #

Post a Comment:
  • HTML Syntax: NOT allowed

Vaibhav Hi, I am Vaibhav Choudhary working in Oracle with JDK team. This blog is all about simple concept of Java, JVM and JavaFX.


« August 2016