• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to call JavaFX_Charts from a java GUI

 
Ria De
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
have a GUI application in Java that collects data and creates a file.
Then i read the file and i need to call the JavaFX_Charts from java and pass the values that i have in the file

how can i do this? create a object JavaFX_Charts? it has main method and start
I run the JavaFX_Charts alone as an applicaation an creates an very nice chart.
How can i produce such a chart with the java and my file.

 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You have to CarefullyChooseOneForum.
I have moved your question to the JavaFX forum as the question is about JavaFX.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You have mentioned that you currently have a GUI application written. I am assuming it is in Swing. Do you want to make a call to JavaFX charts from your existing Swing application?
If so, you can read here on how to do it.
 
Ria De
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranganathan Kaliyur Mannar wrote:Hi,
You have mentioned that you currently have a GUI application written. I am assuming it is in Swing. Do you want to make a call to JavaFX charts from your existing Swing application?
If so, you can read here on how to do it.


here is my GUI class that extends JFrame

do you think i can add part of the example you show me and updae my GUI like that?

 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you actually run that?
 
Ria De
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranganathan Kaliyur Mannar wrote:What happens when you actually run that?


When i run the application a window opens with buttons and text area and i have another class that contains all the methods for the action buttons.
 
Ria De
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranganathan Kaliyur Mannar wrote:What happens when you actually run that?


and in the end i have produced a txt.file with two column values that i read and store the values in to Lists.

And i want to call the application chart and pass these values and display a diagram/chart
Is there another way with java? I want this chart beacuase is more stylish. Can i do somthing similar with java?
Thank you
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok good. So, what you have to do next is:
say, you want to show the chart on the click of a button, you would add an action listener to that button. And inside that, you will initiate a JFXPanel.
If you look again at the tutorial link that I gave earlier, this is done followed by creating a JavaFX scene - and then the setScene() method is called on the JFXPanel instance.

You have to do the same thing. When creating the scene, you will create the LineChart and add that object to the scene. You can use the two lists that you have collected (which have the values) to populate the line chart.
 
John Damien Smith
Ranch Hand
Posts: 296
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your app GUI seems pretty small and you have all the source for it. If it were me, I'd just convert the entire GUI over to JavaFX (build the GUI in SceneBuilder). Then you don't have to worry about threading issues around mixing JavaFX and Swing and learning and mixing two different GUI toolkits. I realize this suggestion is a little bit of overkill for what you are trying to accomplish and using a JFXPanel as suggested by Ranganathan is a fine (and simple) solution, so implement the approach you are most comfortable with.
 
John Damien Smith
Ranch Hand
Posts: 296
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just curious how a straight app conversion would look and compare to a swing app and how much effort it would be.
I know it is not really the topic of your question and probably not what you want to do, but a sample in case you are interested.



probeoil.fxml



Probeoil.java



ProbeoilController.java



SampleData.java



Communicator.java

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic