Difference between revisions of "Build ImageJ2 Plugin With JavaFX"

 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
JavaFX is the new graphical toolkit that will on the long term probably replace Swing. This page aims to give some guidelines to be able to build ImageJ2 plugin with JavaFX.
+
'''JavaFX''' is the new graphical toolkit that will on the long term probably '''replace Swing'''. This page aims to give some guidelines to be able to build ImageJ2 plugin with JavaFX.
  
''Please don't hesitate to edit this page and your tricks and/or experience about JavaFX and ImageJ2.''
+
''Please don't hesitate to edit this page and add your tricks and/or experience about JavaFX and ImageJ2.''
  
Some things to know :
+
== Some things to know ==
  
* JavaFX is only available since Java 8
+
* JavaFX is only available since '''Java 8'''.
* JavaFX is not shipped with OpenJDK but it is with the Oracle JDK.
+
* JavaFX is '''not shipped''' with OpenJDK but it is with the '''Oracle JDK'''.
 
* JavaFX development seems to move to the OpenJFX project : http://openjdk.java.net/projects/openjfx. But it's unclear what is going on for now...
 
* JavaFX development seems to move to the OpenJFX project : http://openjdk.java.net/projects/openjfx. But it's unclear what is going on for now...
* SceneBuilder is a graphical interface that help creating JavaFX FXML files. Oracle stopped distributing SceneBuilder binaries (I don't know why). You can find new binaries from the Gluon project there : http://gluonhq.com/open-source/scene-builder
+
* '''SceneBuilder''' is a graphical interface that help creating JavaFX FXML files. Oracle stopped distributing SceneBuilder binaries (I don't know why). You can find new binaries from the '''Gluon project''' there : http://gluonhq.com/open-source/scene-builder
  
----
+
== Under the hood ==
  
I have created a minimal ImageJ plugin that show how to use JavaFX for the UI of a plugin there : https://github.com/hadim/imagej-plugin-javafx (this plugin should maybe moved to the imagej GitHub organization so any IJ devs can more easly edit).
+
Usually a JavaFX program needs to declare a <tt>javafx.application.Application</tt>. Because only '''one''' <tt>Application</tt> instance can exist at runtime, I think under IJ1/IJ2 interface (using Swing), if you want to use JavaFX you need to use the <tt>javafx.embed.swing.JFXPanel</tt> class which make the link/bridge between a <tt>JFrame</tt> and JavaFX.
 +
 
 +
* An example of the usual <tt>javafx.application.Application</tt> can be found here : https://github.com/hadim/imagej-plugin-javafx/blob/master/src/main/java/net/imagej/plugin/minimalJavaFXPlugin/gui/MainApp.java
 +
 
 +
* An example of how to use <tt>javafx.embed.swing.JFXPanel</tt> can be found here : https://github.com/hadim/imagej-plugin-javafx/blob/master/src/main/java/net/imagej/plugin/minimalJavaFXPlugin/gui/MainAppFrame.java
 +
 
 +
== A minimal ImageJ 2 JavaFX plugin ==
 +
 
 +
I have created a '''minimal ImageJ plugin''' that show how to use JavaFX for the UI of a plugin there : https://github.com/hadim/imagej-plugin-javafx (this plugin should maybe moved to the imagej GitHub organization so any IJ devs can more easly edit).

Latest revision as of 07:56, 12 May 2016

JavaFX is the new graphical toolkit that will on the long term probably replace Swing. This page aims to give some guidelines to be able to build ImageJ2 plugin with JavaFX.

Please don't hesitate to edit this page and add your tricks and/or experience about JavaFX and ImageJ2.

Some things to know

  • JavaFX is only available since Java 8.
  • JavaFX is not shipped with OpenJDK but it is with the Oracle JDK.
  • JavaFX development seems to move to the OpenJFX project : http://openjdk.java.net/projects/openjfx. But it's unclear what is going on for now...
  • SceneBuilder is a graphical interface that help creating JavaFX FXML files. Oracle stopped distributing SceneBuilder binaries (I don't know why). You can find new binaries from the Gluon project there : http://gluonhq.com/open-source/scene-builder

Under the hood

Usually a JavaFX program needs to declare a javafx.application.Application. Because only one Application instance can exist at runtime, I think under IJ1/IJ2 interface (using Swing), if you want to use JavaFX you need to use the javafx.embed.swing.JFXPanel class which make the link/bridge between a JFrame and JavaFX.

A minimal ImageJ 2 JavaFX plugin

I have created a minimal ImageJ plugin that show how to use JavaFX for the UI of a plugin there : https://github.com/hadim/imagej-plugin-javafx (this plugin should maybe moved to the imagej GitHub organization so any IJ devs can more easly edit).