21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package javax.swing.event; 26 27 import java.awt.event.*; 28 import java.awt.*; 29 import javax.swing.*; 30 31 /** 32 * An event reported to a child component that originated from an 33 * ancestor in the component hierarchy. 34 * <p> 35 * <strong>Warning:</strong> 36 * Serialized objects of this class will not be compatible with 37 * future Swing releases. The current serialization support is 38 * appropriate for short term storage or RMI between applications running 39 * the same version of Swing. As of 1.4, support for long term storage 40 * of all JavaBeans™ 41 * has been added to the <code>java.beans</code> package. 42 * Please see {@link java.beans.XMLEncoder}. 43 * 44 * @author Dave Moore 45 */ 46 @SuppressWarnings("serial") 47 public class AncestorEvent extends AWTEvent { 48 /** 49 * An ancestor-component was added to the hierarchy of 50 * visible objects (made visible), and is currently being displayed. 51 */ 52 public static final int ANCESTOR_ADDED = 1; 53 /** 54 * An ancestor-component was removed from the hierarchy 55 * of visible objects (hidden) and is no longer being displayed. 56 */ 57 public static final int ANCESTOR_REMOVED = 2; 58 /** An ancestor-component changed its position on the screen. */ 59 public static final int ANCESTOR_MOVED = 3; 60 61 Container ancestor; 62 Container ancestorParent; 63 64 /** 65 * Constructs an AncestorEvent object to identify a change 66 * in an ancestor-component's display-status. 67 * 68 * @param source the JComponent that originated the event 69 * (typically <code>this</code>) 70 * @param id an int specifying {@link #ANCESTOR_ADDED}, 71 * {@link #ANCESTOR_REMOVED} or {@link #ANCESTOR_MOVED} 72 * @param ancestor a Container object specifying the ancestor-component 73 * whose display-status changed 74 * @param ancestorParent a Container object specifying the ancestor's parent 75 */ 76 public AncestorEvent(JComponent source, int id, Container ancestor, Container ancestorParent) { 77 super(source, id); 78 this.ancestor = ancestor; 79 this.ancestorParent = ancestorParent; 80 } 81 82 /** 83 * Returns the ancestor that the event actually occurred on. 84 * 85 * @return the {@code Container} object specifying the ancestor component 86 */ 87 public Container getAncestor() { 88 return ancestor; 89 } | 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package javax.swing.event; 26 27 import java.awt.event.*; 28 import java.awt.*; 29 import javax.swing.*; 30 31 /** 32 * An event reported to a child component that originated from an 33 * ancestor in the component hierarchy. 34 * <p> 35 * <strong>Warning:</strong> 36 * Serialized objects of this class will not be compatible with 37 * future Swing releases. The current serialization support is 38 * appropriate for short term storage or RMI between applications running 39 * the same version of Swing. As of 1.4, support for long term storage 40 * of all JavaBeans™ 41 * has been added to the {@code java.beans} package. 42 * Please see {@link java.beans.XMLEncoder}. 43 * 44 * @author Dave Moore 45 */ 46 @SuppressWarnings("serial") 47 public class AncestorEvent extends AWTEvent { 48 /** 49 * An ancestor-component was added to the hierarchy of 50 * visible objects (made visible), and is currently being displayed. 51 */ 52 public static final int ANCESTOR_ADDED = 1; 53 /** 54 * An ancestor-component was removed from the hierarchy 55 * of visible objects (hidden) and is no longer being displayed. 56 */ 57 public static final int ANCESTOR_REMOVED = 2; 58 /** An ancestor-component changed its position on the screen. */ 59 public static final int ANCESTOR_MOVED = 3; 60 61 Container ancestor; 62 Container ancestorParent; 63 64 /** 65 * Constructs an AncestorEvent object to identify a change 66 * in an ancestor-component's display-status. 67 * 68 * @param source the JComponent that originated the event 69 * (typically {@code this}) 70 * @param id an int specifying {@link #ANCESTOR_ADDED}, 71 * {@link #ANCESTOR_REMOVED} or {@link #ANCESTOR_MOVED} 72 * @param ancestor a Container object specifying the ancestor-component 73 * whose display-status changed 74 * @param ancestorParent a Container object specifying the ancestor's parent 75 */ 76 public AncestorEvent(JComponent source, int id, Container ancestor, Container ancestorParent) { 77 super(source, id); 78 this.ancestor = ancestor; 79 this.ancestorParent = ancestorParent; 80 } 81 82 /** 83 * Returns the ancestor that the event actually occurred on. 84 * 85 * @return the {@code Container} object specifying the ancestor component 86 */ 87 public Container getAncestor() { 88 return ancestor; 89 } |