For what can I see about your post, you are trying to keep the UI responsive while trying to do a long-running task in Swing.
Unfortunately, Swing is a single thread window system and trying to make long-running tasks will block the UI.
Since Java 1.6 the Swing SDK includes a class called SwingWorker, which allows to execute that kind of tasks in another thread while providing a hook to the UI Thread in order to keep the user updated about how the process is going.
The basic example is given in the Java Tutorial.
SwingWorker worker = new SwingWorker<ImageIcon[], Void>() {
@Override
public ImageIcon[] doInBackground() {
final ImageIcon[] innerImgs = new ImageIcon[nimgs];
for (int i = 0; i < nimgs; i++) {
innerImgs[i] = loadImage(i+1);
}
return innerImgs;
}
@Override
public void done() {
//Remove the "Loading images" label.
animator.removeAll();
loopslot = -1;
try {
imgs = get();
} catch (InterruptedException ignore) {}
catch (java.util.concurrent.ExecutionException e) {
String why = null;
Throwable cause = e.getCause();
if (cause != null) {
why = cause.getMessage();
} else {
why = e.getMessage();
}
System.err.println("Error retrieving file: " + why);
}
}
};
Basically you can define your own SwingWorker to execute the Ping request in the doInBackgroundMethod and keep updating the UI with the method get()
Here is the link to the Java tutorial: http://docs.oracle.com/javase/tutorial/uiswing/concurrency/simple.html
In the Wikipedia there is a detailed explanation on how to use the SwingWorker: http://en.wikipedia.org/wiki/SwingWorker
I Hope this can help you to solve your problem.
Best Regards.