編集:いくつかの問題を修正した後、私が抱えているより大きな問題は、私が使用しているApachePOIが原因です。私は今それを理解することに取り組んでいます。どうやらそれはサンドボックスによって制限されています。
私はSwingを初めて使用し、小さなSwingアプリを作成しました。このアプリは、WebStartを介して実行する必要があります。FileOpenServiceを使用して、テキスト表示を更新しようとしています。FileOpenServiceダイアログが表示されず、テキスト表示が更新されないため、スレッドの問題が発生していると思います。
彼らが今とは違うことをしている例は本当に見つかりません。
アイデア?
ありがとう!
編集:FileOpenServiceダイアログが表示されます。メインをこれに変更しました:
public static void main(String[] args) throws Exception {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new MainFrame();
}
});
}
ただし、それでも表示を更新できません。これは私が更新を行っている場所です:
Runnable r = new Runnable() {
public void run() {
for (final String s : Logger.getMessages())
append(s + "\n");
}
};
try {
if (SwingUtilities.isEventDispatchThread())
r.run();
else
SwingUtilities.invokeAndWait(r);
}
と私のappendメソッド:
private void append(Color c, String s) {// throws Exception {
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY,
StyleConstants.Foreground, c);
int len = _textPaneLog.getDocument().getLength();
try {
_textPaneLog.getDocument().insertString(len, s, aset);
} catch (BadLocationException e) {
e.printStackTrace();
}
}