KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > WizardValidationException


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.openide;
20
21 import javax.swing.JComponent JavaDoc;
22
23
24 /** The exception informs about fail in wizard panel validation and provides
25  * a localized description what's wrong. Also can return JComponent which should
26  * be focused to correct wrong values.
27  *
28  * @author Jiri Rechtacek
29  * @since 4.28
30  */

31 final public class WizardValidationException extends Exception JavaDoc {
32     private String JavaDoc localizedMessage;
33     private JComponent JavaDoc source;
34
35     /** Creates a new instance of WizardValidationException */
36     private WizardValidationException() {
37     }
38
39     /**
40      * Creates a new exception instance.
41      * @param source component which should have focus to correct wrong values
42      * @param message the detail message
43      * @param localizedMessage description notifies an user what value must be corrected
44      */

45     public WizardValidationException(JComponent JavaDoc source, String JavaDoc message, String JavaDoc localizedMessage) {
46         super(message);
47         this.source = source;
48         this.localizedMessage = localizedMessage;
49     }
50
51     /**
52      *
53      * @return JComponent for request focus to correct wrong values
54      * or null if there is no useful component to focus it
55      */

56     public JComponent JavaDoc getSource() {
57         return source;
58     }
59
60     /**
61      *
62      * @return description will notifies an user what value must be corrected
63      */

64     public String JavaDoc getLocalizedMessage() {
65         return (localizedMessage != null) ? localizedMessage : this.getMessage();
66     }
67 }
68
Popular Tags