0

I added to JPanel JWebBrowser. I load html-file with js that load map and json-file with point coordinates as:

webBrowser = new JWebBrowser();
final JPanel webPanel = new JPanel(new BorderLayout());
webPanel.add(webBrowser, BorderLayout.CENTER);
webBrowser.navigate(WebServer.getDefaultWebServer()
          .getClassPathResourceURL(getClass().getName(), "index.html"));

I created a button that update json-file and load new point coordinates in this file. Then I try to refresh the page in the browser to set new points on the map, but jwebbrowser updates only the html-file and js-script, and doesn't load new json-file and as a result old points are marked on the map. If I close the program and open again - everything is ok, there is new points.

So, my problem: how to load the updated json-file with new coordinates of points?

I tried this:

webBrowser.reloadPage();

and I tried jwebbrowser disposing and creating new jwebbrowser, but everything is ineffectual:

            webBrowser.disposeNativePeer();
            webPanel.removeAll();
            webPanel.revalidate();
            webPanel.repaint();

            webBrowser = new JWebBrowser();
            webBrowser.setBarsVisible(false);
            webBrowser.navigate(WebServer.getDefaultWebServer().
                    getClassPathResourceURL(getClass().getName(), "index.html"));
            webPanel.add(webBrowser, BorderLayout.CENTER);
            webPanel.revalidate();
            webPanel.repaint();
Denis
  • 503
  • 8
  • 32

1 Answers1

0

Solution (maybe for somebody it will be useful):

WebServer.stopDefaultWebServer();

It's not necessary to drop JWebBrowser, better way:

WebServer.stopDefaultWebServer();
WebServer.getDefaultWebServer();
webBrowser.navigate(WebServer.getDefaultWebServer()
                        .getClassPathResourceURL(getClass().getName(), "index.html"));
Denis
  • 503
  • 8
  • 32