KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > form > beaninfo > awt > ComponentBeanInfo


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.modules.form.beaninfo.awt;
21
22 import java.awt.Image JavaDoc;
23 import java.beans.*;
24 import org.openide.util.Utilities;
25
26 /** Base class for awt components - toolbars, checkboxes...
27 *
28 * @author Ales Novak
29 * @see sun.java.beans.infos.... or
30 */

31 public class ComponentBeanInfo extends SimpleBeanInfo {
32
33     /** no-arg */
34     ComponentBeanInfo() {
35     }
36
37     /** @return Propertydescriptors */
38     public PropertyDescriptor[] getPropertyDescriptors() {
39         try {
40             return new PropertyDescriptor[] {
41                 new PropertyDescriptor("background", java.awt.Component JavaDoc.class, "getBackground", "setBackground"), // 0 // NOI18N
42
new PropertyDescriptor("foreground", java.awt.Component JavaDoc.class, "getForeground", "setForeground"), //1 // NOI18N
43
new PropertyDescriptor("enabled", java.awt.Component JavaDoc.class, "isEnabled", "setEnabled"), //2 // NOI18N
44
new PropertyDescriptor("name", java.awt.Component JavaDoc.class), //3 // NOI18N
45
new PropertyDescriptor("visible", java.awt.Component JavaDoc.class), //4 // NOI18N
46
new PropertyDescriptor("font", java.awt.Component JavaDoc.class) // NOI18N
47
};
48         } catch (IntrospectionException ex) {
49             return super.getPropertyDescriptors();
50         }
51     }
52     
53     static class Support extends SimpleBeanInfo {
54
55         String JavaDoc iconName;
56         Class JavaDoc beanClass;
57         
58         Support(String JavaDoc icon, Class JavaDoc beanClass) {
59             iconName = icon;
60             this.beanClass = beanClass;
61         }
62
63         public BeanDescriptor getBeanDescriptor() {
64             return new BeanDescriptor(beanClass);
65         }
66
67         /**
68         * Return the icon
69         */

70         public Image JavaDoc getIcon(int type) {
71             if (iconName == null) return null;
72             return Utilities.loadImage("org/netbeans/modules/form/beaninfo/awt/" + iconName + ".gif"); // NOI18N
73
}
74
75         public BeanInfo[] getAdditionalBeanInfo() {
76             return new BeanInfo[] { new ComponentBeanInfo() };
77         }
78
79         /** @return Propertydescriptors */
80         public PropertyDescriptor[] getPropertyDescriptors() {
81             try {
82                 return createPDs();
83             } catch (IntrospectionException ex) {
84                 return null;
85             }
86         }
87             
88         protected PropertyDescriptor[] createPDs() throws IntrospectionException {
89             return new PropertyDescriptor[0];
90         }
91     }
92 }
93
Popular Tags