final ImageExportOptions options,
final String title,
final Frame parent
) throws IOException {
ProgressDialog dialog = Platform.getPlatform().getProgressDialog();
ProgressThread thread = new ProgressThread(dialog) {
public void run() {
try {
// Write the file:
export(engine, options, this);
}
catch (IOException e) {
// This exception should be unpacked in the error handling
// below, following dialog.showProgress().
throw new RuntimeException(e);
}
}
};
dialog.showProgress(parent, thread, title, 0, 10, true);
// Unpack any Throwable, in case it hides a checked exception:
Throwable error = dialog.getThrown();
if (error != null) {
if ( error instanceof IOException )
throw (IOException) error;
if ( error instanceof RuntimeException )
throw (RuntimeException) error;
throw new RuntimeException( error );
}
if (thread.isCanceled()) {
return false;
}
return true;
}