现在的位置: 首页 > 综合 > 正文

javaFx如何链接外部网页(从javafx内部打开新的网页)

2012年07月27日 ⁄ 综合 ⁄ 共 1241字 ⁄ 字号 评论关闭

 

 

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 :

 

 

 

 

 

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 :

 

 

 

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 :).

 

 

抱歉!评论已关闭.