好,因爲我不能設法做到這一點在其他的方式,我發現更多有用的使用默認用戶瀏覽器查看文件。 所以這是我的解決方案:
helpItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Desktop desktop = null;
// Before more Desktop API is used, first check
// whether the API is supported by this particular
// virtual machine (VM) on this particular host.
if (Desktop.isDesktopSupported())
{
try
{
desktop = Desktop.getDesktop();
String thehelpfile= String.valueOf(getClass()
.getResource("help.html"));
File fileToOpen=new File(thehelpfile.substring(5));
desktop.open(fileToOpen);
} catch (IOException ex)
{
JOptionPane.showMessageDialog(null,
ex, "Λάθος", JOptionPane.PLAIN_MESSAGE);
}
}
}
});
謝謝!讀者和目標是什麼? – Vagelism
[aaacch](http://www.java2s.com/Code/JavaAPI/javax.swing/JTextAreareadReaderinObjectdesc.htm),爲所有[JTextComponents](http:// docs。)實現了'read' /'write'方法。 oracle.com/javase/tutorial/uiswing/components/text.html) – mKorbel