KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > ui > SwingBrowser


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
20 package org.netbeans.core.ui;
21
22 import java.beans.*;
23 import java.lang.reflect.Constructor JavaDoc;
24
25 import org.openide.NotifyDescriptor;
26 import org.openide.awt.HtmlBrowser;
27 import org.openide.util.NbBundle;
28
29 /** Factory and descriptions for default Swing based browser
30  */

31
32 public class SwingBrowser implements HtmlBrowser.Factory, java.io.Serializable JavaDoc {
33
34     /** Property name */
35     public static final String JavaDoc PROP_DESCRIPTION = "description"; // NOI18N
36

37     protected transient PropertyChangeSupport pcs;
38
39     private static final long serialVersionUID = -3735603646171376891L;
40     
41     /** Creates new Browser */
42     public SwingBrowser () {
43         init ();
44     }
45
46     /** initialize object */
47     private void init () {
48         pcs = new PropertyChangeSupport (this);
49     }
50
51     /** Getter for browser name
52      * @return browserName name of browser
53      */

54     public String JavaDoc getDescritpion () {
55         return NbBundle.getMessage (SwingBrowser.class, "LBL_SwingBrowserDescription");
56     }
57     
58     /**
59      * Returns a new instance of BrowserImpl implementation.
60      */

61     public HtmlBrowser.Impl createHtmlBrowserImpl() {
62         try {
63             Class JavaDoc<?> clz = Class.forName ("org.openide.awt.SwingBrowserImpl"); // NOI18N
64
Constructor JavaDoc con = clz.getDeclaredConstructor (new Class JavaDoc [] {});
65             con.setAccessible (true);
66             return (HtmlBrowser.Impl)con.newInstance (new Object JavaDoc [] {});
67         }
68         catch (Exception JavaDoc ex) {
69             org.openide.DialogDisplayer.getDefault ().notify (
70                 new NotifyDescriptor.Message (NbBundle.getMessage (SwingBrowser.class, "MSG_cannot_create_browser"))
71             );
72             return null;
73         }
74     }
75     
76     /**
77      * @param l new PropertyChangeListener */

78     public void addPropertyChangeListener (PropertyChangeListener l) {
79         pcs.addPropertyChangeListener (l);
80     }
81     
82     /**
83      * @param l PropertyChangeListener to be removed */

84     public void removePropertyChangeListener (PropertyChangeListener l) {
85         pcs.removePropertyChangeListener (l);
86     }
87     
88     private void readObject (java.io.ObjectInputStream JavaDoc ois)
89     throws java.io.IOException JavaDoc, ClassNotFoundException JavaDoc {
90         ois.defaultReadObject ();
91         init ();
92     }
93 }
94
Popular Tags