繁体   English   中英

PathToFile是什么意思?

[英]What does PathToFile means?

我发现下面的代码可以帮助我显示和修改程序中的docx文件,该文件由user3610008在此处发布: 设置 jeditorpane 的字体和样式 我通过直接链接到文件exp“ c:/bonjour.docx”更改了代码中的PathToFile。 因此,该文件在程序启动时会正确打开,但是我无法从菜单中打开一个新文件。 我认为PathToFile必须关联DocxEditorKit和MetaphaseEditorPanel,但是问题是如何实现的? 此代码来自链接:

DocxEditorKit DEK=new DocxEditorKit;
MetaphaseEditorPanel MEP=new MetaphaseEditorPanel;
MEP.getHTMLTextPane().setEditorKit(DEK);

//Try and Catch blocks of course to read the file
DEK.read(new FileInputStream(PathToFile), MEP.getHTMLTextPane().getDocument(), 0);
getContentPane.add(MEP, BorderLayout.CENTER);

这是我的代码:

DEK=new DocxEditorKit();
MEP=new MetaphaseEditorPanel();
MEP.getHtmlTextPane().setEditorKit(DEK);
FileInputStream input=new FileInputStream("d:/bonjour.docx");
try{
    DEK.read(input, MEP.getHtmlTextPane().getDocument(), 0);
} catch(BadLocationException ble) {
    ble.printStackTrace(); 
}

您是从环境保护部取得的; 也许您之前已经添加了它,而现在执行MEP = new ...则没有将新的MEP对象添加到JFrame中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM