1 7 8 package java.awt.event; 9 10 import java.awt.AWTEvent ; 11 import java.awt.Container ; 12 import java.awt.Component ; 13 14 42 public class ContainerEvent extends ComponentEvent { 43 44 47 public static final int CONTAINER_FIRST = 300; 48 49 52 public static final int CONTAINER_LAST = 301; 53 54 57 public static final int COMPONENT_ADDED = CONTAINER_FIRST; 58 59 62 public static final int COMPONENT_REMOVED = 1 + CONTAINER_FIRST; 63 64 71 Component child; 72 73 76 private static final long serialVersionUID = -4114942250539772041L; 77 78 91 public ContainerEvent(Component source, int id, Component child) { 92 super(source, id); 93 this.child = child; 94 } 95 96 103 public Container getContainer() { 104 return (source instanceof Container ) ? (Container )source : null; 105 } 106 107 112 public Component getChild() { 113 return child; 114 } 115 116 122 public String paramString() { 123 String typeStr; 124 switch(id) { 125 case COMPONENT_ADDED: 126 typeStr = "COMPONENT_ADDED"; 127 break; 128 case COMPONENT_REMOVED: 129 typeStr = "COMPONENT_REMOVED"; 130 break; 131 default: 132 typeStr = "unknown type"; 133 } 134 return typeStr + ",child="+child.getName(); 135 } 136 } 137 | Popular Tags |