KickJava   Java API By Example, From Geeks To Geeks.

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


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.beans.*;
23 import java.util.ResourceBundle JavaDoc;
24
25 import org.openide.util.NbBundle;
26 import java.awt.Scrollbar JavaDoc;
27
28 /** A BeanInfo for java.awt.ScrollBar.
29 *
30 * @author Ales Novak
31 */

32 public class ScrollbarBeanInfo extends ComponentBeanInfo.Support {
33
34     public ScrollbarBeanInfo() {
35         super("scrollbar", java.awt.Scrollbar JavaDoc.class); // NOI18N
36
}
37
38     /** @return Propertydescriptors */
39     protected PropertyDescriptor[] createPDs() throws IntrospectionException {
40         PropertyDescriptor[] pds = new PropertyDescriptor[] {
41             new PropertyDescriptor("unitIncrement", Scrollbar JavaDoc.class), // NOI18N
42
new PropertyDescriptor("minimum", Scrollbar JavaDoc.class), // NOI18N
43
new PropertyDescriptor("maximum", Scrollbar JavaDoc.class), // NOI18N
44
new PropertyDescriptor("value", Scrollbar JavaDoc.class), // NOI18N
45
new PropertyDescriptor("blockIncrement", Scrollbar JavaDoc.class), // NOI18N
46
new PropertyDescriptor("orientation", Scrollbar JavaDoc.class), // NOI18N
47
new PropertyDescriptor("visibleAmount", Scrollbar JavaDoc.class), // NOI18N
48
};
49         pds[5].setPropertyEditorClass(ScrollbarBeanInfo.OrientationPropertyEditor.class);
50         return pds;
51     }
52
53     /** orientation PropertyEditor */
54     public static class OrientationPropertyEditor extends PropertyEditorSupport {
55         String JavaDoc[] tags;
56         
57         /** @return tags */
58         public synchronized String JavaDoc[] getTags() {
59             if (tags == null) {
60                 ResourceBundle JavaDoc rb = NbBundle.getBundle(ScrollbarBeanInfo.class);
61                 tags = new String JavaDoc[] {
62                     rb.getString("HORIZONTAL"),
63                     rb.getString("VERTICAL"),
64                 };
65             }
66             return tags;
67         }
68
69         public void setAsText(String JavaDoc s) {
70             Integer JavaDoc i;
71             getTags();
72             if (s.equals(tags[0])) i = new Integer JavaDoc(Scrollbar.HORIZONTAL);
73             else i = new Integer JavaDoc(Scrollbar.VERTICAL);
74             setValue(i);
75         }
76
77         public String JavaDoc getAsText() {
78             int i = ((Integer JavaDoc) getValue()).intValue();
79             getTags();
80             return i == Scrollbar.VERTICAL ? tags[1] : tags[0];
81         }
82
83         public String JavaDoc getJavaInitializationString() {
84             int i = ((Integer JavaDoc) getValue()).intValue();
85             return i == Scrollbar.VERTICAL ? "java.awt.Scrollbar.VERTICAL" : "java.awt.Scrollbar.HORIZONTAL"; // NOI18N
86
}
87     }
88 }
89
Popular Tags