Skip to main content

How to display HTML w/ Javascript using java code?

No replies
marklim
Offline
Joined: 2008-08-26
Points: 0

Here is my code snippet.
The test.html contains HTML code and Javascript code.
When using JEditorPane, it only supports pure HTML.

Any idea on what else I can use? and how to use it?
Thanks

public static void main (String args[])
{
URL url = null;
JEditorPane web = new JEditorPane();
try
{
url = new URL("file:////tmp/test.html");
web.setEditable(false);
web.setPage (url);
}catch (Exception e)

{
System.out.println ("Error = " + e);
}

JFrame f = new JFrame ("name here");

f.setDefaultCloseOperation (JFrame.DO_NOTHING_ON_CLOSE);
f.getContentPane().add(web);
f.setSize(512,342);
f.setVisible (true);

}