source: trunk/gcc/libjava/java/awt/event/ContainerEvent.java

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 4.6 KB
Line 
1/* ContainerEvent.java -- components added/removed from a container
2 Copyright (C) 1999, 2002 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38
39package java.awt.event;
40
41import java.awt.Component;
42import java.awt.Container;
43
44/**
45 * This event is generated when a component is added or removed from a
46 * container. Applications do not ordinarily need to handle these events
47 * since the AWT system handles them internally.
48 *
49 * @author Aaron M. Renn <arenn@urbanophile.com>
50 * @see ContainerAdapter
51 * @see ContainerListener
52 * @since 1.1
53 * @status updated to 1.4
54 */
55public class ContainerEvent extends ComponentEvent
56{
57 /**
58 * Compatible with JDK 1.1+.
59 */
60 private static final long serialVersionUID = -4114942250539772041L;
61
62 /** This is the first id in the id range used by this class. */
63 public static final int CONTAINER_FIRST = 300;
64
65 /** This is the last id in the id range used by this class. */
66 public static final int CONTAINER_LAST = 301;
67
68 /** This id indicates a component was added to the container. */
69 public static final int COMPONENT_ADDED = 300;
70
71 /** This id indicates a component was removed from the container. */
72 public static final int COMPONENT_REMOVED = 301;
73
74 /**
75 * The non-null child component that was added or removed.
76 *
77 * @serial the child component that changed
78 */
79 private final Component child;
80
81 /**
82 * Initializes a new instance of <code>ContainerEvent</code> with the
83 * specified source and id. Additionally, the affected child component
84 * is also passed as a parameter. Note that an invalid id leads to
85 * unspecified results.
86 *
87 * @param source the source container of the event
88 * @param id the event id
89 * @param child the child component affected by this event
90 * @throws IllegalArgumentException if source is null
91 */
92 public ContainerEvent(Component source, int id, Component child)
93 {
94 super(source, id);
95 this.child = child;
96 }
97
98 /**
99 * Returns the source of this event as a <code>Container</code>.
100 *
101 * @return the source of the event
102 * @throws ClassCastException if the source is changed to a non-Container
103 */
104 public Container getContainer()
105 {
106 return (Container) source;
107 }
108
109 /**
110 * This method returns the child object that was added or removed from
111 * the container.
112 *
113 * @return the child object added or removed
114 */
115 public Component getChild()
116 {
117 return child;
118 }
119
120 /**
121 * This method returns a string identifying this event. It is formatted as:
122 * <code>(getID() == COMPONENT_ADDED ? "COMPONENT_ADDED"
123 * : "COMPONENT_REMOVED") + ",child=" + getChild().getName()</code>.
124 *
125 * @return a string identifying this event
126 */
127 public String paramString()
128 {
129 // Unlike Sun, we don't throw NullPointerException if child is illegally
130 // null.
131 return (id == COMPONENT_ADDED ? "COMPONENT_ADDED,child="
132 : id == COMPONENT_REMOVED ? "COMPONENT_REMOVED,child="
133 : "unknown type,child=") + (child == null ? "" : child.getName());
134 }
135} // class ContainerEvent
Note: See TracBrowser for help on using the repository browser.