将HTML文件加载到JEditorPane中 [英] Loading html file into JEditorPane

查看:104
本文介绍了将HTML文件加载到JEditorPane中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我如何将一个html文档加载到JEditorPane中。我已经尝试了以下似乎不起作用的功能:

  try {
URL h = new URL(file ://test.html);
pane.setPage(h);
} catch(Exception e){}


解决方案

在java的jeditor窗格中打开html文件


$ b

  JeditorPane editorpane = new JEditorPane(); 
editorScrollPane = new JScrollPane(editorpane);
editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_​​ALWAYS);
档案档案=新档案(F://test.htm);
editorpane.setPage(file.toURI()。toURL());
editorpane.setEditable(true);

希望这会帮助你,
在这里工作


Would anyone be able to tell me how I could load a html document into a JEditorPane. I have tried the following which does not seem to work:

try{
    URL h = new URL("file://test.html");
    pane.setPage(h); 
} catch (Exception e) {}

解决方案

Open html file in jeditor pane in java

       JeditorPane editorpane= new JEditorPane();
       editorScrollPane = new JScrollPane(editorpane);
       editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
       File file = new File("F://test.htm");
       editorpane.setPage(file.toURI().toURL());
       editorpane.setEditable(true);

Hope this will help you, Here this is working

这篇关于将HTML文件加载到JEditorPane中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆