1 7 8 package java.awt.event; 9 10 import java.awt.AWTEvent ; 11 import java.awt.Event ; 12 import java.awt.Component ; 13 import java.awt.Rectangle ; 14 15 48 public class ComponentEvent extends AWTEvent { 49 50 53 public static final int COMPONENT_FIRST = 100; 54 55 58 public static final int COMPONENT_LAST = 103; 59 60 63 public static final int COMPONENT_MOVED = COMPONENT_FIRST; 64 65 68 public static final int COMPONENT_RESIZED = 1 + COMPONENT_FIRST; 69 70 73 public static final int COMPONENT_SHOWN = 2 + COMPONENT_FIRST; 74 75 78 public static final int COMPONENT_HIDDEN = 3 + COMPONENT_FIRST; 79 80 83 private static final long serialVersionUID = 8101406823902992965L; 84 85 96 public ComponentEvent(Component source, int id) { 97 super(source, id); 98 } 99 100 107 public Component getComponent() { 108 return (source instanceof Component ) ? (Component )source : null; 109 } 110 111 117 public String paramString() { 118 String typeStr; 119 Rectangle b = (source !=null 120 ? ((Component )source).getBounds() 121 : null); 122 123 switch(id) { 124 case COMPONENT_SHOWN: 125 typeStr = "COMPONENT_SHOWN"; 126 break; 127 case COMPONENT_HIDDEN: 128 typeStr = "COMPONENT_HIDDEN"; 129 break; 130 case COMPONENT_MOVED: 131 typeStr = "COMPONENT_MOVED ("+ 132 b.x+","+b.y+" "+b.width+"x"+b.height+")"; 133 break; 134 case COMPONENT_RESIZED: 135 typeStr = "COMPONENT_RESIZED ("+ 136 b.x+","+b.y+" "+b.width+"x"+b.height+")"; 137 break; 138 default: 139 typeStr = "unknown type"; 140 } 141 return typeStr; 142 } 143 } 144 | Popular Tags |