admin管理员组文章数量:1415420
I've made a simple JAVA program to show a HTML page. But I cant seem to get the JAVA SCRIPT on the html page to work in the program. I use it to make calculations. If I open the HTML page in the browser it does work. Can someone help how i also get it to work in my JAVA program?
Below you'll find the code.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication16;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.io.FileReader;
/**
*
* @author chris
*/
public class JavaApplication16 {
/**
* @param args the mand line arguments
*/
public static void main(String[] args) throws Exception {
String url = "/";
JEditorPane editor = new JEditorPane("/");
editor.setEditable(true);
JScrollPane pane = new JScrollPane(editor);
JFrame f = new JFrame("calculatie Program");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(pane);
f.setSize(800, 600);
f.setVisible(true);
}
}
I've made a simple JAVA program to show a HTML page. But I cant seem to get the JAVA SCRIPT on the html page to work in the program. I use it to make calculations. If I open the HTML page in the browser it does work. Can someone help how i also get it to work in my JAVA program?
Below you'll find the code.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication16;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.io.FileReader;
/**
*
* @author chris
*/
public class JavaApplication16 {
/**
* @param args the mand line arguments
*/
public static void main(String[] args) throws Exception {
String url = "http://members.multimania.nl/c75/";
JEditorPane editor = new JEditorPane("http://members.multimania.nl/c75/");
editor.setEditable(true);
JScrollPane pane = new JScrollPane(editor);
JFrame f = new JFrame("calculatie Program");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(pane);
f.setSize(800, 600);
f.setVisible(true);
}
}
Share
Improve this question
asked Sep 13, 2012 at 14:13
user1668855user1668855
231 silver badge3 bronze badges
4 Answers
Reset to default 2Standard java ponents support very basic HTML only. They do not support either JavaScript or any advanced elements introduced during that last 10 (or may be even 15) years.
You should use pure java browser. There are several implementations. The following discussion may help you: Pure Java HTML viewer/renderer for use in a Scrollable pane
JEditorPane
doesn't support Javascript. The easiest alternative would be to use either JxBrowser (mercial) or SWT's Browser widget.
Try using Rhino to process the javascript... Otherwise it's a dead end.
Please take a look at the swt browser ponent, but I too would remend rhino, if all you want is running putations written in js.
本文标签: JAVA program to show a HTML page Javascript in html doesnt workStack Overflow
版权声明:本文标题:JAVA program to show a HTML page. Javascript in html doesnt work - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745199617a2647307.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论