3

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.

  • 1
    It's not a duplicate I want to now what the better way is, just to implement a JavaFX Chart on a swing Panel or to do it in a other way. –  Nov 25 '15 at 07:50
  • You can see this I have searched. I hope this will help you little. http://stackoverflow.com/questions/15221084/using-javafx-chart-in-swing-application – mubeen Nov 25 '15 at 07:56
  • It seems to be a good idea to implement a JavaFX Chart in a swing application, but how can I add a JavaFX Panel to a "normal" Java Swing Panel? –  Nov 25 '15 at 07:59

3 Answers3

0

JFXPanel is the component that will help Java Fx content to embed in Java swing application See This. You can read the tutorial here

mubeen
  • 813
  • 2
  • 18
  • 39
0

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.

hurricane
  • 6,521
  • 2
  • 34
  • 44
0

Use a JFX Panel on a normal JPanel, in the Oracle Documenation you can finde more Information about it.

Pascal
  • 1,255
  • 5
  • 20
  • 44