KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > form > RADContainer


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
21 package org.netbeans.modules.form;
22
23 import java.util.ArrayList JavaDoc;
24
25 /**
26  *
27  * @author Ian Formanek
28  */

29 public class RADContainer extends RADComponent implements ComponentContainer {
30     private ArrayList JavaDoc subComponents;
31
32     public RADComponent[] getSubBeans() {
33         RADComponent[] components = new RADComponent [subComponents.size()];
34         subComponents.toArray(components);
35         return components;
36     }
37
38     public void initSubComponents(RADComponent[] initComponents) {
39         subComponents = new ArrayList JavaDoc(initComponents.length);
40         for (int i = 0; i < initComponents.length; i++) {
41             subComponents.add(initComponents[i]);
42             initComponents[i].setParentComponent(this);
43         }
44     }
45
46     public void reorderSubComponents(int[] perm) {
47         RADComponent[] components = new RADComponent[subComponents.size()];
48         for (int i=0; i < perm.length; i++)
49             components[perm[i]] = (RADComponent) subComponents.get(i);
50
51         subComponents.clear();
52         subComponents.addAll(java.util.Arrays.asList(components));
53     }
54
55     public void add(RADComponent comp) {
56         subComponents.add(comp);
57         comp.setParentComponent(this);
58     }
59
60     public void remove(RADComponent comp) {
61         if (subComponents.remove(comp))
62             comp.setParentComponent(null);
63     }
64
65     public int getIndexOf(RADComponent comp) {
66         return subComponents.indexOf(comp);
67     }
68
69     /**
70      * Called to obtain a Java code to be used to generate code to access the
71      * container for adding subcomponents. It is expected that the returned
72      * code is either ""(in which case the form is the container) or is a name
73      * of variable or method call ending with
74      * "."(e.g. "container.getContentPane()."). This implementation returns
75      * "", as there is no sense to add visual components to non-visual
76      * containers
77      * @return the prefix code for generating code to add subcomponents to this container
78      */

79     public String JavaDoc getContainerGenName() {
80         return ""; // NOI18N
81
}
82 }
83
Popular Tags