samples/exceptions/src/org/apidesign/exceptions/trycatchredo/UserQuestionException.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sun, 01 Feb 2009 16:03:37 +0100
changeset 310 fba31e9504a1
parent 309 1687adb2b7f0
permissions -rw-r--r--
QueryException interactive example
     1 package org.apidesign.exceptions.trycatchredo;
     2 
     3 import java.io.IOException;
     4 import javax.swing.JOptionPane;
     5 
     6 /** Specialized I/O exception to request some kind of user confirmation.
     7  * A code that needs to ask user shall not attempt to open a dialog itself,
     8  * rather it shall emit this exception and let its callers show the dialog
     9  * at appropriate time.
    10  *
    11  * @author Jaroslav Tulach
    12  * @since 2.0
    13  */
    14 public abstract class UserQuestionException extends IOException {
    15     /** Description of the dialog to show to the user. Whoever catches
    16      * this exception shall use {@link #getQuestionPane()}.{@link JOptionPane#createDialog(java.lang.String)}
    17      * to construct and display the dialog.
    18      * 
    19      * @return the pane to display to user
    20      */
    21     public abstract JOptionPane getQuestionPane();
    22     /** When the user confirms (or rejects) message presented by the
    23      * {@link #getQuestionPane()} dialog, the exception shall be notified
    24      * by calling this method with {@link JOptionPane#getValue()} option.
    25      *
    26      * @param option the option selected by the user
    27      */
    28     public abstract void confirm(Object option);
    29 }