Using JavaFX Chart in Swing Application - java

I have a traditional Java swing application (extends JFrame and has a main class) that uses JFreeCharts for some charting functionality. I have recently seen JavaFX and think these charts look alot refresher and will give my users a better experience. I wish to embed a JavaFX chart scene into a jInternalFrame (which in turn is called from my jDesktopPane).
I have followed a simple tutorial on how to create both a javafx application and a javafx chart but I am stuck on to how I get the scene inside my existing code. One example I have been through shows me how to achieve this but means converting my project to a javafx one which extends "application" class.
How can I achieve what I want? Is it not possible to keep my existing JFrame as the top level class and simply add a JFXPanel to my jinternalframe.
Any help would be great, please note I have been through some tutorials and they require me to convert my project to javafx - I simply want a javafx scene in my existing swing app.
Many thanks,

You don't need to convert your Swing application to a JavaFX application. You can place a JavaFX Chart in a JFXPanel which may be placed in a Swing component. The javadoc I linked includes sample code for embedding a JavaFX node in a Swing application.
Review the official JavaFX for Swing Developers tutorial trail from Oracle.
Also look at the Embedding JavaFX in Swing sample of SwingInterop for embedding a chart in a Swing application. The sample is provided by Oracle under the BSD open source license so that you can use it in your application.
Despite all this, my advice, unless it is a large, existing Swing code base that you just want to use a couple of JavaFX features in, is to write your application as a pure JavaFX application rather than a mixed Swing/JavaFX application.

Related

how to use ArcGis in javafx

i am using ArcGIS Library for a geospatial project. the sample codes available in their website was fully in java Swing. i need to do path animation in it using javaFX. is it possible.? if yes, can any one suggest me a sample code to create a map.?
Sample code for creating a map in Swing
I don't think you can pull this off using JavaFX, since JMap extends JComponent and is a class provided by the ArcGIS. Unless, they release a version which is supporting JavaFX, things are not very good.
The least you can do is to embed this JMap into a JavaFX application using SwingNode. An example on how to achieve this can be found here.
I am not sure what you want to achieve, when you say "path animation in it", but if it has something that can be achieved without using the internal components of JMap, you can do it !
JMap is a Swing component. JavaFX 1 was built on Swing and supported wrapping a Swing component. JavaFX 2 does not use Swing and does not support wrapping a Swing component. It is anticipated that the upcoming JavaFX 8 will support using Swing components in a JavaFX application.
UPDATE: ArcGIS Runtime is getting support for JavaFX! See http://blogs.esri.com/esri/arcgis/2014/09/17/arcgis-runtime-plays-at-10-2-4/ for details.
You have some options:
Go back to JavaFX 1 (not a good idea IMO)
Turn it around and use JavaFX components in a Swing application (see http://docs.oracle.com/javafx/2/swing/swing-fx-interoperability.htm)
Wait for Java 8, or go get the developer preview of Java 8.
Wait for ArcGIS Runtime 10.2.4 (to be released any day now), which will have beta support for JavaFX.
Sources:
How to wrap a swing component in a javaFX 2.0 application
Class SwingNode (JavaFX 8)
Maybe a bit late but... ArcGIS Runtime for Java's latest beta (Quartz) offers much more JavaFX support.
https://developers.arcgis.com/java/beta/guide/release-notes-java.htm

CSS on Java Swing from Java Code

I am designing a eclipse plugin, where i use Components of Swing and JavaFx. In this I can apply CSS on JavaFX. But i could not apply CSS for Swing components. I was forced to use Swing component for some features of the plugin. So i would like to apply CSS for Swing components too. Is there any api that supports CSS on Swing component?
//This code applies css for javafx components
SwingJavaFxSample.class.getResource("samples.css").toExternalForm();
Please help me in applying css for Swing components too.
You can not use the JavaFX CSS support on Swing controls so to me the question makes no sense. Let me also say that using 3 UI-Technologies together is not really a good idea you'll run into many threading issues (SWT & FX share the same event thread whereas Swing is on another one), ... .
What is the reason you still need Swing? JavaFX can be embedded directly into SWT.

Adding JavaFx to an applet

Hello everyone i am quite new to JavaFx and is currently creating my programs with JavaFx Scene builder. i have never been a pro at creating GUI's and therefore the JavaFx Scene builder allows me to optimize the visual effects!
Ive been given an assignment at work to create an applet for one of our companies websites, the content of the applet should be a graph that will show some detailed information.
Since i enjoy JavaFx and and i find the graphs that you can create in JavaFx and manipulate in CSS quite awesome i wanted to use JavaFx to create my applet.
My Question is however am i able to use JavaFx scene builder to create my applet aswell or am i forced to write to code from scrats?
Also on a side note does anyone know any tutorials on how to apply JavaFx to an Applet ive been looking for some on Google but i only found some pretty advanced guides?
EDIT
I did find a tutorial on Applets for JavaFx however it did not state anything about JavaFx Scene builder
Link: JavaFx Applet tutorial
Yes, you can use JavaFX scene builder with applets, I work as a website administrator for an educational project that require applets to plot graphs, communicate with hardware and look nice and stay secure and hard to download; that is why we are using JavaFX for most of our applets.
Even though I am not involved in the applet making process but I know for a fact that we use JavaFX scene builder to create the graphical user interface.
Also the main reason for creating JavaFX and JavaFX scene builder was for creating applets, because this is what Oracle intended from the sart.

JavaFx 2.0 GUI within the Netbeans Platform Application

Is there any way to integrate JavaFx 2.0 GUI within the Netbeans Platform Application? I've tried searching the topic but did not come across what I was looking for.
I am not very familiar with Netbeans RCP but it is swing based so you can embed your Java FX 2 components the same way you would embed them in a Swing application: use JFXPanels for the FX2/Swing bridge and then embed those panels in RCP the same way you would add a Swing component.
I have also seen
this tutorial but have not tried it
and this related question on SO.

Swing Menu that can be customized by user

Is there any framework or lib out there to create a Java swing menue that can be edited by the user via drag and drop?
Added: Implementing a polished solution myself can take a lot of time. What i would like to see: display the entry while dragging, opening submenus automaticially, showing a line where the item would be placed when releasing the mouse. Actually like the windows startmenu in XP. This would take a lot of time, i am still hoping to find framework or a subclassed Jmenu with these features.
You can implement drag and drop on most (all?) Swing components. See this tutorial to get started.
Update: based on your updated question. have a look at JFrameBuilder (note that its not free).
JFrameBuilder is an easy-to-use visual Java GUI builder.
JFrameBuilder provides the application GUI solution for Java developers. It enables Java developers to create sophisticated Swing GUI applications using drag-and-drop interface without spending a lot of time writing code.
Personally I find it a lot simpler to write pretty UIs in SWT (the toolkit used by Eclipse), it has more access to the underlying OS and provides a richer experience that's closer to what you're after in my opinion. Here's a guide to implementing drag and drop in SWT.

Categories

Resources