JavaFX Webview

+1 Rutger Benoot · April 11, 2015
I was wondering if anyone knows how I can pass an object to a JavaFX WebView. To give some more info on what should happen:
I'm creating an application with an object that contains a list of months and a month contains it average temperature and total amount of downfall:

public class Klimatogram implements Serializable {
   private List maanden;

public class Maand implements Serializable {

    private double temperatuur;
    private int neerslag;


there are ofcourse getters for these values.

In my JavaFX application, I have created the following to render an html-page:
public class Browser extends Region{
        private final WebView webView = new WebView();
        private final WebEngine webEngine = webView.getEngine();
        public Browser(){

With this I can show an html page, but I need to visualize the months so I was wondering how to get the data into the WebView so I can handle it using JavaScript. It would also be helpful if someone could tell me how to get it back out of the WebView.

The reason I need to get the data back, is because the user will be able to change the data in the WebView.

I hope someone can help me. If I haven't provided enough information, please let me know.

Post a Reply


Oldest  Newest  Rating
0 Branislav Lazic · April 11, 2015
Why would you pass data to WebView to handle it using JavaScript? You can obviously do that by using Java. Plus, you don't even need WebView. Just display your data in TableView. First column: Month, second column: average temperature, third column: total amount of downfall.
0 Rutger Benoot · April 11, 2015
The problem (which I haven't actually mentioned) is that it has to visualized using graphs, and those graphs have to be stacked. I've tried some things with a stackpane and bar/linechart but I can't seem to get it right, so the WebView would be the easiest since I still have some code I could reuse
0 Branislav Lazic · April 11, 2015
What do you mean by "stacked"? Any visual example? Picture maybe?
0 Rutger Benoot · April 11, 2015
An image when the program was running:

What it looked like in JavaFX Scene Builder:
0 Branislav Lazic · April 11, 2015
I don't get it. What do you actually want to achieve? You want to display multiple series or what?
0 Rutger Benoot · April 12, 2015
I don't really know how to explain it, but I've found a solution for my problem:

JSObject window = (JSObject) webEngine.executeScript("window");

                    Klimatogram k = controller.getHuidigKlimatogram();

                    window.setMember("klimatogram", controller.getHuidigKlimatogram());

and I've also found a very interesting video about the JavaFX WebView, if anyone ever needs it:
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator