samples/exceptions/src/org/apidesign/exceptions/trycatchredo/UserQuestionException.java
1 package org.apidesign.exceptions.trycatchredo;
3 import java.io.IOException;
4 import javax.swing.JOptionPane;
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
11 * @author Jaroslav Tulach
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.
19 * @return the pane to display to user
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.
26 * @param option the option selected by the user
28 public abstract void confirm(Object option);