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
Related
This question already has answers here:
Drawing a simple line graph in Java
(6 answers)
Closed 7 years ago.
I want to draw a Line Chart out of a double Array, what's the best way to do it in swing? Is there something like in JavaFX?:
series.getData().add(new XYChart.Data(1, 23));
Or should is the best way to implement a Java FX Line Chart in Swing? It's not a duplicate, because I want to know what the better is to go.
Use a JFX Panel on a normal JPanel, in the Oracle Documenation you can finde more Information about it.
JFXPanel is the component that will help Java Fx content to embed in Java swing application
See This. You can read the tutorial here
Which one is better?
If you will use JavaFx just delete Swing in your project. JavaFx is new and have a lot of components fast and useful. Swing is always behind it.
Including two jars?
It is like going somehere with two car. When you add JavaFx to your Swing project you have to find compatible jars Swing and JavaFx. And it is expensive for your project. You got two library and these are doing same thing.
What you can do, what will you see?
I think you are using Swing with JDK 1.6. or 1.7 And you can use JavaFx 2.2 but DON'T FORGET if you use that JavaFx you have to install JavaFx Runtime to your computer. And not only you! You have to install Runtime to other users which are using your jnlp.
And if your structure based on JDK 1.8 there is no problem. Java 8 have JavaFx SDK.
And when you add JavaFx to Swing some components will not work or will work slowly.
What i suggest?
Use one library! Choose one and just it. Change your Swing Project to JavaFx project because it future of Java Desktop Application.
And if you don't want to change your project don't use JavaFx then. Use swing components.
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.
I've heard rumors of people creating their own custom libraries for one, but I have yet to find one for myself. I need it because I need to mount another running applet (in a JPanel in Swing) for my application.
No, at least not in an officially supported way.
There is the SwingView in the ThingsFX 3rd party library to do this.
I've never tried it, so I can't recommend for or against it.
ThingsFX has a website.
Here is a screenshot of Swing components rendered on a JavaFX Stage using ThingsFX.
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.
I am learning JavaFX. I'm adding it to a Java Desktop App and I'm doing this using Netbeans 7. I've been searching the internet for JavaFX examples for whatever I want to do (embed in swing, set background, add gradient, incorporate animation...). I am finding two JavaFX styles.
1st Example: http://download.oracle.com/javafx/2.0/visual_effects/jfxpub-visual_effects.htm
2nd Example: http://javafx.com/samples/MediaBox/
I also found this http://netbeans.org/features/javafx/composer.html which says JavaFX support is currently not available in NetBeans IDE 7.0. And the screen shot is handling an FX Project which I don't have a choice to make in my Netbeans 7. I do have sample FX projects that I can make but these are really Java projects with FX in it (the 1st style of FX).
My guess is that JavaFX has been somewhat redesigned in the latest version, JavaFX 2. The 2nd example being the older style and the 1st being the newer. It seems to me that the 1st example is more like an addition to Java instead of a separate language.
Did I guess right? What's up with the two styles of FX?
The NetBeans JavaFX Composer is a tool that create CustomNodes with JavaFX components, but works with JavaFX 1.3.
NetBeans 7.0 has a JavaFX plug-in, but to version 2.0 (actually in beta).
JavaFX 1.3 is a DSL script language that runs over JVM and JavaFX 2.0 returns to be a Java API. They are totally differents, but conserving same Classes and ideas (CSS style, visual effects, etc).