KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > gumby > swing > widgets > JTabbedPanePeer


1 package org.sapia.gumby.swing.widgets;
2
3 import java.awt.Component JavaDoc;
4
5 import javax.swing.JTabbedPane JavaDoc;
6
7 import org.sapia.util.xml.confix.ConfigurationException;
8 import org.sapia.util.xml.confix.ObjectCreationCallback;
9 import org.sapia.util.xml.confix.ObjectHandlerIF;
10
11 /**
12  * @author Yanick Duchesne
13  *
14  * <dl>
15  * <dt><b>Copyright: </b>
16  * <dd>Copyright &#169; 2002-2005 <a HREF="http://www.sapia-oss.org">Sapia Open
17  * Source Software </a>. All Rights Reserved.</dd>
18  * </dt>
19  * <dt><b>License: </b>
20  * <dd>Read the license.txt file of the jar or visit the <a
21  * HREF="http://www.sapia-oss.org/license.html">license page </a> at the Sapia
22  * OSS web site</dd>
23  * </dt>
24  * </dl>
25  */

26 public class JTabbedPanePeer extends JTabbedPane JavaDoc {
27
28   static final long serialVersionUID = 1L;
29
30   public Tab createTab() {
31     return new Tab(this);
32   }
33
34   public static final class Tab implements ObjectCreationCallback,
35       ObjectHandlerIF {
36
37     private String JavaDoc _title;
38     private Component JavaDoc _comp;
39     private JTabbedPanePeer _owner;
40
41     Tab(JTabbedPanePeer owner) {
42       _owner = owner;
43     }
44
45     public void setTitle(String JavaDoc title) {
46       _title = title;
47     }
48
49     public void setComponent(Component JavaDoc comp) {
50       _comp = comp;
51     }
52
53     /**
54      * @see org.sapia.util.xml.confix.ObjectCreationCallback#onCreate()
55      */

56     public Object JavaDoc onCreate() throws ConfigurationException {
57       _owner.addTab(_title == null ? "" : _title, _comp);
58       return this;
59     }
60
61     /**
62      * @see org.sapia.util.xml.confix.ObjectHandlerIF#handleObject(java.lang.String,
63      * java.lang.Object)
64      */

65     public void handleObject(String JavaDoc arg0, Object JavaDoc obj)
66         throws ConfigurationException {
67       if(obj instanceof Component JavaDoc) {
68         setComponent((Component JavaDoc) obj);
69       } else {
70         throw new IllegalStateException JavaDoc("Expecting instance of: "
71             + Component JavaDoc.class.getName() + "; got: " + obj.getClass().getName());
72       }
73     }
74
75   }
76
77 }
78
Popular Tags