KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwt > awt > event > ContainerEvent


1 /*
2    SwingWT
3    Copyright(c)2003-2004, Tomer Bartletz
4  
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7  
8    Contact me by electronic mail: tomerb@users.sourceforge.net
9
10    $Log: ContainerEvent.java,v $
11    Revision 1.2 2003/12/22 08:48:17 bobintetley
12    Fixed up DnD to build temporarily
13
14
15  */

16 package swingwt.awt.event;
17
18 import swingwt.awt.Component;
19 import swingwt.awt.Container;
20
21 /**
22  * An event that indicates a container movement/resizing/visibility etc.
23  *
24  * @author Tomer Barletz, tomerb@users.sourceforge.net
25  * @version 0.1
26  */

27 public class ContainerEvent extends ComponentEvent {
28     public static final int CONTAINER_FIRST=300;
29     public static final int CONTAINER_LAST=301;
30     public static final int COMPONENT_ADDED=CONTAINER_FIRST;
31     public static final int COMPONENT_REMOVED=1+CONTAINER_FIRST;
32
33     Component child; //The component that is being added or removed from the container
34

35     /**
36      *
37      * @param source the Component that originated the event
38      * @param id type of event
39      * @param child the component that was added or removed
40      */

41     public ContainerEvent(Component source, int id, Component child) {
42         super(source, id);
43         this.child = child;
44     }
45
46     /**
47      * Returns the originator of the event.
48      *
49      * @return the Container object that originated the event
50      */

51     public Container getContainer() {
52         return (Container)source; // cast should always be OK, type was checked in constructor
53
}
54
55     /**
56      *
57      * @return the Component object that was added or removed
58      */

59     public Component getChild() {
60         return child;
61     }
62 }
63
Popular Tags