jtulach@307: package org.apidesign.exceptions.trycatchredo; jtulach@307: jtulach@307: import java.io.IOException; jtulach@309: import javax.swing.JOptionPane; jtulach@307: jtulach@310: /** Specialized I/O exception to request some kind of user confirmation. jtulach@310: * A code that needs to ask user shall not attempt to open a dialog itself, jtulach@310: * rather it shall emit this exception and let its callers show the dialog jtulach@310: * at appropriate time. jtulach@307: * jtulach@307: * @author Jaroslav Tulach jtulach@310: * @since 2.0 jtulach@307: */ jtulach@307: public abstract class UserQuestionException extends IOException { jtulach@310: /** Description of the dialog to show to the user. Whoever catches jtulach@310: * this exception shall use {@link #getQuestionPane()}.{@link JOptionPane#createDialog(java.lang.String)} jtulach@310: * to construct and display the dialog. jtulach@310: * jtulach@310: * @return the pane to display to user jtulach@310: */ jtulach@309: public abstract JOptionPane getQuestionPane(); jtulach@310: /** When the user confirms (or rejects) message presented by the jtulach@310: * {@link #getQuestionPane()} dialog, the exception shall be notified jtulach@310: * by calling this method with {@link JOptionPane#getValue()} option. jtulach@310: * jtulach@310: * @param option the option selected by the user jtulach@310: */ jtulach@309: public abstract void confirm(Object option); jtulach@307: }