+ boolean abort;
+ JDialog timeout_dialog;
+ boolean timeout_started = false;
+
+ private void stop_timeout_dialog() {
+ if (timeout_started) {
+ timeout_started = false;
+ Runnable r = new Runnable() {
+ public void run() {
+ timeout_dialog.setVisible(false);
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+ }
+
+ private void start_timeout_dialog_internal() {
+
+ Object[] options = { "Cancel" };
+
+ JOptionPane pane = new JOptionPane();
+ pane.setMessage(String.format("Connecting to %s, %7.3f MHz", device.toShortString(), frequency));
+ pane.setOptions(options);
+ pane.setInitialValue(null);
+
+ timeout_dialog = pane.createDialog(frame, "Connecting...");
+
+ timeout_dialog.setVisible(true);
+
+ Object o = pane.getValue();
+ if (o == null)
+ return;
+ if (options[0].equals(o))
+ abort = true;
+ timeout_dialog.dispose();
+ timeout_dialog = null;
+ }
+
+ private boolean check_timeout() {
+ if (!timeout_started && frame != null) {
+ if (!SwingUtilities.isEventDispatchThread()) {
+ timeout_started = true;
+ Runnable r = new Runnable() {
+ public void run() {
+ start_timeout_dialog_internal();
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+ }
+ return abort;
+ }
+
+ public void flush_input() throws InterruptedException {