EDIT: After fixing a few issues, the bigger issue that I am having is being caused by Apache POI which I am using. I am working on figuring that out now. Apparently it is being restricted by the Sandbox.
I'm very new to Swing, and created a small Swing app that I now need to have run via web start. I'm trying to use the FileOpenService and update a Text display. I think I am running into threading issues, because the FileOpenService dialog never appears, and my text display is not getting updated.
I can't really find any examples where they are doing anything different than I am right now.
Ideas?
Thanks!
Edit: I now have the FileOpenService dialog appearing. I changed my main to this:
public static void main(String[] args) throws Exception {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new MainFrame();
}
});
}
However, I still can't get my display to update. This is where I am doing the update:
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);
}
and my append method:
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();
}
}