NetBeans Platform Development in JavaFX!
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.
- Login or register to post comments
- 15534 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)




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
Milos Kleint replied on Sat, 2010/03/20 - 10:30am
Ron Pressler replied on Sat, 2010/03/20 - 6:04pm
brian shultz replied on Sat, 2010/03/20 - 10:06pm
Miguel Garcia-lopez replied on Sun, 2010/03/21 - 7:46am
Erik Martino replied on Sun, 2010/03/21 - 11:42am
Anees Ur-rehman replied on Mon, 2010/03/22 - 9:28pm
Oliver Rettig replied on Wed, 2010/03/24 - 3:43am
Geertjan Wielenga replied on Wed, 2010/03/24 - 3:59am
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
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
Damiao Castro replied on Thu, 2010/07/01 - 6:02pm
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
Setya Djajadinata replied on Wed, 2011/11/30 - 9:42am