1

I am trying to put an offline Openstreetmap map into my Java Application. I have found an example here: http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JEditorPane.html

However when I tried to change the URL in the program to the file that is in my computer, it did not work. The HTML page that I am trying to display has JavaScript and I think this is why it will not appear. (I tried displaying a different HTML which was more simple and only had an image to display and it worked.)

Is there a way to embed an HTML file in a Java Application that supports JavaScript? Or is something else preventing the application from displaying my HTML file?

edit: I am trying to embed an HTML file with an OpenLayers Javascript. I have come across the Lobo Browser, it seems like what I am looking for. However when I try to visit a site in the browser, it only show's me a blank page. I am sure that my Java is updated. Has anyone had experience with the Lobo Browser and have an idea as to why it is not working for me?

meebee
  • 251
  • 1
  • 7
  • 17

5 Answers5

1

You can try JavaFX. I found some nice alternatives that I'm willing to try here:

jewelsea
  • 150,031
  • 14
  • 366
  • 406
Rudolph
  • 11
  • 1
1

Is there a way to embed an HTML file in a Java Application that supports JavaScript?

Possibly by embedding support for the the Rhino engine or the ScriptEngine into the HTMLEditorKit.

Note that I have considered trying to do that myself, but since it seems like a lot of effort for little chance of success, I always avoided doing so.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
1

As per this reply:

JEditorPane has limited html and css support. It does not support javascript or applets.

An alternate solution suggested is trying to embed Gecko in your application.

Community
  • 1
  • 1
shams
  • 3,460
  • 24
  • 24
0

I suppose that shouldnot be a problem. It wud be helpful if you could paste the code in that file you are pointing to(the one containing javascript that you suspect is not working).

Galaxin
  • 474
  • 2
  • 9
  • 21
0

I have found this similar question: Embed a web browser within a java application

There are many different answers there. Mozswing worked for me: http://sourceforge.net/projects/mozswing/

Community
  • 1
  • 1
meebee
  • 251
  • 1
  • 7
  • 17