View Javadoc

1   /*
2      Copyright 2002-2006 Martin van den Bemt
3   
4      Licensed under the Apache License, Version 2.0 (the "License");
5      you may not use this file except in compliance with the License.
6      You may obtain a copy of the License at
7   
8          http://www.apache.org/licenses/LICENSE-2.0
9   
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15  */
16  package org.xulux.guilayer.swing.util;
17  
18  import java.awt.Component;
19  
20  import javax.swing.JComponent;
21  
22  import org.xulux.api.gui.IParentWidgetHandler;
23  
24  /**
25   * Destroys/Initializes all components created by xulux.
26   * This is only used in scenarios where xulux is used
27   * on top of an already existing application
28   *
29   * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
30   * @version $Id: SwingParentWidgetHandler.java,v 1.1 2005/12/18 12:58:22 mvdb Exp $
31   */
32  public class SwingParentWidgetHandler implements IParentWidgetHandler {
33  
34      /**
35       *
36       */
37      public SwingParentWidgetHandler() {
38      }
39  
40      /**
41       * @see org.xulux.api.gui.IParentWidgetHandler#initialize(java.lang.Object)
42       */
43      public void initialize(Object parent) {
44      }
45  
46      /**
47       * @see org.xulux.api.gui.IParentWidgetHandler#destroy(java.lang.Object)
48       */
49      public void destroy(Object parent) {
50          if (parent == null) {
51              return;
52          }
53          if (parent instanceof Component) {
54              JComponent comp = (JComponent) parent;
55              comp.removeAll();
56          }
57      }
58  
59  }