1 6 21 22 package de.schlichtherle.swing.event; 23 24 import de.schlichtherle.swing.EnhancedPanel; 25 26 import java.awt.AWTEvent ; 27 import java.awt.Window ; 28 29 48 public class PanelEvent extends AWTEvent { 49 50 51 public static final int ANCESTOR_WINDOW_SHOWN = RESERVED_ID_MAX + 1; 52 53 54 public static final int ANCESTOR_WINDOW_HIDDEN = RESERVED_ID_MAX + 2; 55 56 58 public PanelEvent(EnhancedPanel source, int id) { 59 super(source, id); 60 61 switch (id) { 62 case ANCESTOR_WINDOW_SHOWN: 63 case ANCESTOR_WINDOW_HIDDEN: 64 break; 65 66 default: 67 throw new IllegalArgumentException (); 68 } 69 } 70 71 75 public EnhancedPanel getSourcePanel() { 76 return source instanceof EnhancedPanel ? (EnhancedPanel) source : null; 77 } 78 79 83 public Window getAncestorWindow() { 84 EnhancedPanel panel = getSourcePanel(); 85 return panel != null ? panel.getAncestorWindow() : null; 86 } 87 88 public String paramString() { 89 switch (id) { 90 case ANCESTOR_WINDOW_SHOWN: 91 return "id=ANCESTOR_WINDOW_SHOWN"; 92 93 case ANCESTOR_WINDOW_HIDDEN: 94 return "id=ANCESTOR_WINDOW_HIDDEN"; 95 96 default: 97 throw new AssertionError (); 98 } 99 } 100 } 101 | Popular Tags |