Geertjan is a DZone Zone Leader and has posted 467 posts at DZone. You can read more from them at their website. View Full User Profile

NetBeans Platform Development in JavaFX!

03.19.2010
| 20346 views |
  • submit to reddit

The NetBeans team is busy enabling NetBeans Platform developers to integrate JavaFX components into their applications.

Since there is no official way of accessing JavaFX from Swing, the NetBeans team will provide open-sourced API equivalents of JavaFX components. Developers will be able to include the Open API JavaFX library in their NetBeans Platform applications. Currently, this is what the API looks like:

The above API enables you to code your NetBeans modules purely in JavaFX. As an example of using NetBeans APIs in a pure JavaFX module, this code would display a NetBeans TopComponent containing all the JavaFX demos (which extend the "DemoPart" class) registered in the NetBeans Lookup:

var lkp = Lookup {type: org.netbeans.modules.javafx.example.DemoPart.class};

var tc = SceneTopComponent {
   name: "Installed demos"
   scene : Scene {
       width: 1000
       height: 800
       content: [
               Flow {
                   hgap: 20, vgap: 20
                   padding: Insets {
                       bottom: 20, left: 20, right: 20, top: 20
                   }                 
                   content: bind for (demo in lkp.result) DemoNode {demo: demo as DemoPart}
               }
           ]
   }
}

tc.display();
A new project template will be provided in NetBeans IDE. It will have an enriched build.xml file, containing an Ant script that will enable the above code to be compiled to bytecode. The required dependencies, such as to the JavaFX SDK, will also be predefined in the template.

Within the support class in the API shown above, the JavaFX components are mapped to Java. For example, an Action is part of the support class. Therefore, in the layer of the module where you'd like to use the Action, you create an Action instance like this:

  <folder name="Menu">
      <folder name="Window">
           <folder name="Other">
               <file name="ShowFXDemo.instance">
                   <attr name="instanceClass" stringvalue="javax.swing.Action"/>
                   <attr name="instanceCreate" methodvalue="org.netbeans.javafx.Support.action"/>
                   <attr name="action" stringvalue="org.netbeans.modules.javafx.example.Action"/>
                   <attr name="displayName" bundlevalue="org.netbeans.modules.javafx.example.Bundle#ShowFXDemo"/>
               </file>
           </folder>
       </folder>
   </folder> 

On the basis of the above, the three demos below have been created:

Above you see three demos, each created in JavaFX and integrated into a NetBeans Platform "TopComponent", i.e., a window in a NetBeans Platform application. For example, this is the definition of "Demo1" above:

package org.netbeans.modules.javafx.example;

import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.layout.Panel;
import javafx.scene.layout.LayoutInfo;

public class Demo1 extends DemoPart {

   public override function create() {
       var n = Rectangle {
           layoutX: 25 layoutY: 25
           width: 50, height: 50
           fill: Color.GREEN
           rotate: 10
       }
Panel {
layoutInfo: LayoutInfo { width: 100 height: 100 }
content: [n]
       }
   }

}

The NetBeans team is looking for feedback to this new development, as well as for your usecases. They will also be submitting a paper to JavaOne around this theme. 

 

Published at DZone with permission of its author, Geertjan Wielenga.

Comments

Guido Amabili replied on Sat, 2010/03/20 - 3:59am

 

I think it would be great to have a JavaFX Application Framework like the SAF.

I for one do not need to integrate javafx components into a swing application. (But many developers on mailing lists have such an use case)

I developed myself a little framework kind of nano-griffon to build an extensible java application.

Just implement some interface (in javafx or java), and your components gets deployed.

Nothing magical, just a customized classloader that can load jars and hot deploy bundles.

No osgi, no netbeans plugin system, although I am now reevaluating my initial decision.

Because for these frameworks, you have already tools in IDEs.

Guido

 

 

 

Garcia Mario replied on Sat, 2010/03/20 - 5:59am

It's great, I think it's very important that java desktop technologies can connect to each other. I'm currently working in a open source swing framework and in the next release I'm planning to mix some javafx components with a swing application in the demo. I've already made a custom solution to the javafx-to-swing problem but I'll take a look to the netbeans solution. The real problem is that when you create an animation there's a new Thread running in your swing app and you have to take care of killing it before shutting down the application.

Good article, good news to Swing!

Sven Reimers replied on Sat, 2010/03/20 - 8:14am

Finally!!! How long have we been waiting for this!! Anyway to get our hand on the demo code for trying some things out?

Milos Kleint replied on Sat, 2010/03/20 - 10:30am

does the Netbeans javafx integration actually work within the netbeans module projects? AFAIK many features only work within the javafx dedicated project type. At least people reported to me that javafx support is not present in maven based projects.

Ron Pressler replied on Sat, 2010/03/20 - 6:04pm

This is great. Thanks.

brian shultz replied on Sat, 2010/03/20 - 10:06pm

I am glad to see they are making this effort,shows me that they wont abandon the idea of integrating javafx into swing.

Miguel Garcia-lopez replied on Sun, 2010/03/21 - 7:46am

This is great news! Congrats for the iniciative, I'm looking forward to have some time and try it. I'd be specially happy if I get to test some NBP app with built-in JavaFX media support. Thanks again!

Erik Martino replied on Sun, 2010/03/21 - 11:42am

And without starting the netbeans platform app in webstart I hope, right?

Anees Ur-rehman replied on Mon, 2010/03/22 - 9:28pm

is it ready to make our hand dirty?

Oliver Rettig replied on Wed, 2010/03/24 - 3:43am

JavaFX components inside Netbeansplatform Apps is really great. I am interested especially in using the movieplayer of JavaFX with the possibility of overlay graphics in my netbeans apps.

Geertjan Wielenga replied on Wed, 2010/03/24 - 3:59am

Please note that all of this is still at an experimental point at this stage. Watch this space at a future date for further details, inc. timeline etc.

Mauricio Lopez replied on Thu, 2010/03/25 - 12:56pm

Would love to see a new type of IDE being developed ala http://java.dzone.com/articles/code-bubbles-ide-revolution.

This type of capability on the NB platform would really be the only way of doing it.

 

 

Manuel Paniagua replied on Thu, 2010/03/25 - 3:28pm

For me it's GREAT,  javaFX and swing in the same editor it's a power exponential for Java 

Loke Odin replied on Thu, 2010/03/25 - 7:05pm

Combining all the cool features of JavaFX with the NetBeans Platform and Visual library!!! 

This is just AMAZING!!!

Shawn Huang replied on Tue, 2010/06/08 - 11:00pm

Lovely. javafx is no longer *useless*.

Damiao Castro replied on Thu, 2010/07/01 - 6:02pm

anyone has an example project to download? can't put this to work :(

Frederic Le Breton replied on Thu, 2010/08/12 - 7:28am

Hi Geertjan,

First please excuse me for bad english

Second, a very big thanks to you for your great blog with a lot very interesting articles.

Third, i'm very interesting to develop netbeans platform application with javafx components into,  have you some news about this ?

 

Very big thanks !

Ariel Landaida replied on Tue, 2010/09/21 - 6:17am

hello, could show an example of CRUD but using purely JavaFX? if you can with oracle database, thank you very much

Setya Djajadinata replied on Wed, 2011/11/30 - 9:42am

How is the progress of this feature ?

Mateo Gomez replied on Fri, 2012/07/27 - 4:54am

isnt JAVAFX cool..i think so

mexican dessert recipes

Matt Coleman replied on Thu, 2012/10/25 - 3:17am in response to: Ariel Landaida

yes,,,a sample would be helpful

present for graphic designer 

Muhammad Danial replied on Mon, 2014/03/31 - 7:07am

 Developers will be able to include the Open API JavaFX library in their NetBeans Platform applications. Currently, this is what the API looks like:

Ge fridge repairs (london)

Black Men replied on Fri, 2014/04/11 - 7:21am

 The NetBeans team is busy enabling NetBeans Platform developers to integrate JavaFX components into their applications. 

Greg Aziz

Black Men replied on Sun, 2014/04/13 - 12:25am

will surely hold steady as one of 2009's touchstones, one whose exclusion from lists of year-end-bests would represent a more profound gesture than its inclusion. Yet here I am, haplessly enveloped into the nebulous realm of "universal acclaim," kicking my pebble of praise at the foot of the imminent mountain..
soundcloud downloader soundcloud downloader

Black Men replied on Mon, 2014/04/14 - 8:33am

  JavaFX module, this code would display a NetBeans TopComponent containing all the JavaFX demos (which extend the "DemoPart" class) registered in the NetBeans Lookup:

Read this page

Black Men replied on Tue, 2014/04/15 - 8:36am

 Developers will be able to include the Open API JavaFX library in their NetBeans Platform applications. Currently, this is what the API looks like:

Best Buy Coupons

Samad Khatri replied on Tue, 2014/04/15 - 9:41am in response to: Guido Amabili

 World Stem Cell Institute is a 501 (c ) 3 non-profit corporation doing stem cell research, education and clinical trial using stem cell treatments. Eye diseases stem cell treatment

Black Men replied on Wed, 2014/04/16 - 7:40am

  Το home button, παρά τις φήμες, παραμένει στη θέση του ενώ, σε αντίθεση με προηγούμενες υλοποιήσεις της Apple, η νέα ταμπλέτα της είναι πιο παχιά (κατά 6 χιλιοστά) και πιο βαριά (κατά 50 γραμμάρια) από τον προκάτοχό της. 

hip hop beat making software

Black Men replied on Thu, 2014/04/17 - 11:44am

 παραμένει στη θέση του ενώ, σε αντίθεση με προηγούμενες υλοποιήσεις της Apple, η νέα ταμπλέτα της είναι πιο παχιά (κατά 6 χιλιοστά) και πιο βαριά (κατά 50 γραμμάρια) από τον προκάτοχό της. 

predict gender of baby

Black Men replied on Thu, 2014/04/17 - 11:51am

 Developers will be able to include the Open API JavaFX library in their NetBeans Platform applications. Currently, this is what the API looks like: 

Read about Bert Griffin

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.