Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在java浏览器中启用javascript?_Java_User Interface_Jeditorpane - Fatal编程技术网

如何在java浏览器中启用javascript?

如何在java浏览器中启用javascript?,java,user-interface,jeditorpane,Java,User Interface,Jeditorpane,可能重复: 我有一个相对简单的小型web浏览器,我希望在浏览器中启用Javascript。我该如何做呢?我希望保持浏览器相对简单,但任何改进或建议都将受到极大欢迎。 这是密码。 提前谢谢 public class javamark13 { static String command ; static JEditorPane epane; static JPanel panel; static JFrame frame ; static JTextField field ; static J

可能重复:

我有一个相对简单的小型web浏览器,我希望在浏览器中启用Javascript。我该如何做呢?我希望保持浏览器相对简单,但任何改进或建议都将受到极大欢迎。 这是密码。 提前谢谢

public class javamark13 {

static String command ;
static JEditorPane epane;
static JPanel panel;
static JFrame  frame ;
static JTextField field ;
static JLabel  label;
static JButton  button ;
static JScrollBar bar ;


public static void main (String[] args){
    //design of the jpanel  jframe
    frame=new  JFrame ("Lotta Browser ");
    frame.setVisible(true );
    frame.setLocation(1,1);
    frame .setSize(1000,700);
    panel =new JPanel ();
    label=new JLabel("                         Enter a URL");
    label.setBounds(50,5,50,20);
    panel.add(label);
    button=new JButton("Search");
    button.setBounds(870, 0, 110, 25);

    frame .setContentPane(panel);
    panel.setBackground(Color.gray);
    panel .setLayout(null);
    epane=new JEditorPane();
    epane.setEditable(false);
    epane .setBounds(1, 25, panel.getWidth(),panel.getHeight());
    panel.add(epane);
    field=new JTextField ();
    panel.add(button);
    field.setBounds(75,1,panel.getWidth()-191,23);
    panel.add(field);




    //******************************************************


    button.addActionListener(new ActionListener(){

        @Override
        public void actionPerformed(ActionEvent arg0) {
            command =field.getText();
            String  http="http://www.";
            String com=".com/";
            command=http +command+com;
            field.setText(command);
            try {
                epane.setPage(new URL(command));
            } catch (MalformedURLException e) {

                e.printStackTrace();
            } catch (IOException e) {

                e.printStackTrace();
            };

        }});





};

}

请参见此处发布的答案:


简而言之:JEditorPane对html和css的支持有限,不支持javascript或小程序。

“我希望浏览器相对简单”我想你会发现你的两个目标不一致。浏览器DOM几乎是设计膨胀的典型产物,实现Javascript支持的第一步是为浏览器提供与HTML DOM兼容的接口。这就是为什么人们使用已经完成大部分工作的渲染引擎,比如WebKit或Gecko。