I've not read you're previous question, however...
The basic problem you have is needing to notify the dialog (which is within the EDT) that the background thread has completed (as well as provide feedback to the user if possible).
This is covered in the Concurrency in Swing lesson.
Below is a simple proof of concept. Personal, I would normally construct a custom panel and put it onto the a JDialog, but this just a proof of concept.
public class TestSwingWorker {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException ex) {
} catch (InstantiationException ex) {
} catch (IllegalAccessException ex) {
} catch (UnsupportedLookAndFeelException ex) {
}
final JDialog dialog = new JDialog((Frame)null, "Happy, Happy, Joy, Joy", true);
// This is so I can get my demo to work, you won't need it...
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(new EmptyBorder(8, 8, 8, 8));
dialog.setContentPane(panel);
// You'll need you own icon...
JLabel lblIcon = new JLabel(new ImageIcon(getClass().getResource("/waiting-64.png")));
JLabel lblMessage = new JLabel("<html>Hard and work here<br>Please wait...</html>");
final JProgressBar progressBar = new JProgressBar();
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.NORTH;
gbc.weighty = 1;
gbc.insets = new Insets(2, 2, 2, 2);
gbc.gridheight = GridBagConstraints.REMAINDER;
dialog.add(lblIcon, gbc);
gbc.gridheight = 1;
gbc.gridx = 1;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gbc.weighty = 0;
gbc.weightx = 1;
dialog.add(lblMessage, gbc);
gbc.gridy = 1;
gbc.anchor = GridBagConstraints.NORTH;
gbc.weighty = 1;
dialog.add(progressBar, gbc);
dialog.pack();
dialog.setLocationRelativeTo(null);
MyWorker worker = new MyWorker();
// Get notification back from the worker...
worker.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
MyWorker worker = (MyWorker) evt.getSource();
// Progress has been updated
if (evt.getPropertyName().equalsIgnoreCase("progress")) {
progressBar.setValue((Integer)evt.getNewValue());
// The state of the worker has changed...
} else if (evt.getPropertyName().equalsIgnoreCase("state")) {
if (worker.getState().equals(SwingWorker.StateValue.DONE)) {
dialog.dispose();
}
}
}
});
worker.execute();
dialog.setVisible(true);
}
});
}
protected static class MyWorker extends SwingWorker<Object, Object> {
@Override
protected Object doInBackground() throws Exception {
// My long running task...
for (int index = 0; index < 100; index++) {
// Change this to make it faster or slower...
Thread.sleep(250);
setProgress(index);
}
return null;
}
}
}