1 7 8 package java.awt.event; 9 10 import java.awt.AWTEvent ; 11 import java.awt.Component ; 12 import java.awt.Container ; 13 14 61 public class HierarchyEvent extends AWTEvent { 62 63 66 public static final int HIERARCHY_FIRST = 1400; 68 72 public static final int HIERARCHY_CHANGED = HIERARCHY_FIRST; 73 74 77 public static final int ANCESTOR_MOVED = 1 + HIERARCHY_FIRST; 78 79 82 public static final int ANCESTOR_RESIZED = 2 + HIERARCHY_FIRST; 83 84 87 public static final int HIERARCHY_LAST = ANCESTOR_RESIZED; 88 89 93 public static final int PARENT_CHANGED = 0x1; 94 95 109 public static final int DISPLAYABILITY_CHANGED = 0x2; 110 111 128 public static final int SHOWING_CHANGED = 0x4; 129 130 Component changed; 131 Container changedParent; 132 long changeFlags; 133 134 152 public HierarchyEvent(Component source, int id, Component changed, 153 Container changedParent) { 154 super(source, id); 155 this.changed = changed; 156 this.changedParent = changedParent; 157 } 158 159 180 public HierarchyEvent(Component source, int id, Component changed, 181 Container changedParent, long changeFlags) { 182 super(source, id); 183 this.changed = changed; 184 this.changedParent = changedParent; 185 this.changeFlags = changeFlags; 186 } 187 188 195 public Component getComponent() { 196 return (source instanceof Component ) ? (Component )source : null; 197 } 198 199 205 public Component getChanged() { 206 return changed; 207 } 208 209 222 public Container getChangedParent() { 223 return changedParent; 224 } 225 226 234 public long getChangeFlags() { 235 return changeFlags; 236 } 237 238 244 public String paramString() { 245 String typeStr; 246 switch(id) { 247 case ANCESTOR_MOVED: 248 typeStr = "ANCESTOR_MOVED ("+changed+","+changedParent+")"; 249 break; 250 case ANCESTOR_RESIZED: 251 typeStr = "ANCESTOR_RESIZED ("+changed+","+changedParent+")"; 252 break; 253 case HIERARCHY_CHANGED: { 254 typeStr = "HIERARCHY_CHANGED ("; 255 boolean first = true; 256 if ((changeFlags & PARENT_CHANGED) != 0) { 257 first = false; 258 typeStr += "PARENT_CHANGED"; 259 } 260 if ((changeFlags & DISPLAYABILITY_CHANGED) != 0) { 261 if (first) { 262 first = false; 263 } else { 264 typeStr += ","; 265 } 266 typeStr += "DISPLAYABILITY_CHANGED"; 267 } 268 if ((changeFlags & SHOWING_CHANGED) != 0) { 269 if (first) { 270 first = false; 271 } else { 272 typeStr += ","; 273 } 274 typeStr += "SHOWING_CHANGED"; 275 } 276 if (!first) { 277 typeStr += ","; 278 } 279 typeStr += changed + "," + changedParent + ")"; 280 break; 281 } 282 default: 283 typeStr = "unknown type"; 284 } 285 return typeStr; 286 } 287 } 288 | Popular Tags |