class ConfirmTerminateTask implements Runnable {
int result = JOptionPane.NO_OPTION;
String subSystem = null;
// Store the subsystem name for display
public void setSubSystem(String subSystem) {
this.subSystem = subSystem;
}
// Did the user request subsystem termination?
boolean terminateTask() {
return (result == JOptionPane.YES_OPTION);
}
// Build the complete message and display the option dialog.
// Store the user's choice.
public void run() {
StringBuffer buffer = new StringBuffer(subSystem);
buffer.append(" has failed. Switch off?");
result =
JOptionPane.showConfirmDialog(SwingClient.this,
buffer.toString(), "Subsystem Failure",
JOptionPane.YES_NO_OPTION);
}
}