summaryrefslogtreecommitdiff
path: root/altosui/AltosFlashUI.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-11-25 17:29:28 -0800
committerKeith Packard <keithp@keithp.com>2010-11-25 17:29:28 -0800
commitb8f05cdc0e9b4a96852eed9d38ff6d5950e2d2ed (patch)
tree5543c71cc0d0b73343a1980aa6d7cd5970d70cb2 /altosui/AltosFlashUI.java
parentadbb14c63d85b7a54223f88ac623571456f4a462 (diff)
altosui: Clean up flash code to ensure swing gets called from right thread
This moves all of the flash code to a separate thread and passes messages back to the swing thread to keep the UI up to date. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosFlashUI.java')
-rw-r--r--altosui/AltosFlashUI.java25
1 files changed, 12 insertions, 13 deletions
diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java
index 0b61f041..0302ccd3 100644
--- a/altosui/AltosFlashUI.java
+++ b/altosui/AltosFlashUI.java
@@ -49,13 +49,21 @@ public class AltosFlashUI
public void actionPerformed(ActionEvent e) {
if (e.getSource() == cancel) {
- abort();
+ setVisible(false);
dispose();
} else {
String cmd = e.getActionCommand();
- if (cmd.equals("done"))
- ;
- else if (cmd.equals("start")) {
+ if (e.getID() == -1) {
+ JOptionPane.showMessageDialog(frame,
+ e.getActionCommand(),
+ file.toString(),
+ JOptionPane.ERROR_MESSAGE);
+ setVisible(false);
+ dispose();
+ } else if (cmd.equals("done")) {
+ setVisible(false);
+ dispose();
+ } else if (cmd.equals("start")) {
setVisible(true);
} else {
pbar.setValue(e.getID());
@@ -64,11 +72,6 @@ public class AltosFlashUI
}
}
- public void abort() {
- if (flash != null)
- flash.abort();
- }
-
public void build_dialog() {
GridBagConstraints c;
Insets il = new Insets(4,4,4,4);
@@ -186,7 +189,6 @@ public class AltosFlashUI
file_value.setText(file.toString());
setVisible(true);
flash.flash();
- flash = null;
}
} catch (FileNotFoundException ee) {
JOptionPane.showMessageDialog(frame,
@@ -205,9 +207,6 @@ public class AltosFlashUI
file.toString(),
JOptionPane.ERROR_MESSAGE);
} catch (InterruptedException ie) {
- } finally {
- abort();
}
- dispose();
}
} \ No newline at end of file