KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > form > layoutsupport > DefaultLayoutSupport


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.layoutsupport;
21
22 import java.awt.*;
23
24 /**
25  * This class is used internally to provide default support for any layout
26  * manager class. The layout manager is handled as a JavaBean, no component
27  * constraints are supported, as well as no drag&drop and no arranging
28  * features.
29  *
30  * @author Tomas Pavek
31  */

32
33 class DefaultLayoutSupport extends AbstractLayoutSupport {
34
35     private Class JavaDoc layoutClass;
36
37     public DefaultLayoutSupport(Class JavaDoc layoutClass) {
38         this.layoutClass = layoutClass;
39     }
40
41     public Class JavaDoc getSupportedClass() {
42         return layoutClass;
43     }
44
45     public void addComponentsToContainer(Container container,
46                                          Container containerDelegate,
47                                          Component[] components,
48                                          int index)
49     {
50         // for better robustness catch exceptions that might occur because
51
// the default support does not deal with constraints
52
try {
53             super.addComponentsToContainer(container,
54                                            containerDelegate,
55                                            components,
56                                            index);
57         }
58         catch (RuntimeException JavaDoc ex) { // just ignore
59
ex.printStackTrace();
60         }
61     }
62
63     /** Cloning method - creates a new instance of this layout support, just
64      * not initialized yet.
65      * @return new instance of this layout support
66      */

67     protected AbstractLayoutSupport createLayoutSupportInstance() {
68         return new DefaultLayoutSupport(layoutClass);
69     }
70 }
71
Popular Tags