Using JavaFX Chart in Swing Application

后端 未结 1 1373
借酒劲吻你
借酒劲吻你 2021-01-23 04:24

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 th

相关标签:
1条回答
  • 2021-01-23 04:55

    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.

    0 讨论(0)
提交回复
热议问题