Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

displaying animated GIF while thread is working

807588Oct 17 2008 — edited Jan 24 2009
I'm having problems displaying an animated GIF while my thread is working. I started a new thread that opens and external program to process some data. While that is processing, I want to show an animated GIF on the GUI to show the user something is happening.

Here is my actionPerformed method that happens when the user clicks "submit".
public void actionPerformed(ActionEvent actionEvent){
              waiting.setText("Please wait a moment...");
              routeNum.setText("Route Num: " + (String)jBox.getSelectedItem());
              myDDAGPS.add(icon);
              myDDAGPS.update(myDDAGPS.getGraphics());
              int inputs = 1;
              boolean moreDevices = true;
              while(moreDevices) {
                  DataLoggerInterface dll = new DataLoggerInterface(inputs);
                  Thread t = new Thread(dll);
                  t.start();
                  try {
                      t.join();
                      waiting.setText("All done!");
                  } catch (InterruptedException ex) {
                      ex.printStackTrace();
                  }
                  String yesOrNo = JOptionPane.showInputDialog("Do you have any more devices to enter in? (y/n)");
                  if(yesOrNo.equalsIgnoreCase("n") || yesOrNo.equalsIgnoreCase("no")) {
                    moreDevices = false;
                  }
                  else {
                    JOptionPane.showMessageDialog(null, "Hit OK when you have the next device plugged in.");
                  }
                  inputs++;
                  myDDAGPS.remove(waiting);
                  myDDAGPS.remove(icon);
              }
        }
And here is my DataLoggerInterface class
public class DataLoggerInterface implements Runnable {
int inputs;
DataLoggerInterface(int inputs) {
    this.inputs = inputs;
}
    public void run() {
        Runtime rt = Runtime.getRuntime();
        Process p;
        try {
            p = rt.exec("C:/dda-gps/Temp/GPSBabel/gpsbabel.exe -w -t -i mtk -f com3 -o kml -F C:/dda-gps/Temp/input" + String.valueOf(inputs) + ".kml");
            p.waitFor();
            p.destroy();
        } catch (Exception ex) {
            ex.printStackTrace();
        }               
    }
}
Any help would be appreciated.
Thanks

Edited by: dmikester1 on Oct 17, 2008 11:59 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 21 2009
Added on Oct 17 2008
11 comments
574 views