Over a million developers have joined DZone.

NetBeans Platform Development in JavaFX!

DZone's Guide to

NetBeans Platform Development in JavaFX!

· Java Zone
Free Resource

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

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}

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"/>

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. 


Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}