1 package org.sapia.gumby.swing.widgets; 2 3 import java.awt.Component ; 4 5 import javax.swing.JTabbedPane ; 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 26 public class JTabbedPanePeer extends JTabbedPane { 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 _title; 38 private Component _comp; 39 private JTabbedPanePeer _owner; 40 41 Tab(JTabbedPanePeer owner) { 42 _owner = owner; 43 } 44 45 public void setTitle(String title) { 46 _title = title; 47 } 48 49 public void setComponent(Component comp) { 50 _comp = comp; 51 } 52 53 56 public Object onCreate() throws ConfigurationException { 57 _owner.addTab(_title == null ? "" : _title, _comp); 58 return this; 59 } 60 61 65 public void handleObject(String arg0, Object obj) 66 throws ConfigurationException { 67 if(obj instanceof Component ) { 68 setComponent((Component ) obj); 69 } else { 70 throw new IllegalStateException ("Expecting instance of: " 71 + Component .class.getName() + "; got: " + obj.getClass().getName()); 72 } 73 } 74 75 } 76 77 } 78 | Popular Tags |