01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Michael Danilov
19: * @version $Revision$
20: */package java.awt.event;
21:
22: import java.awt.Component;
23: import java.awt.Container;
24:
25: public class ContainerEvent extends ComponentEvent {
26:
27: private static final long serialVersionUID = -4114942250539772041L;
28:
29: public static final int CONTAINER_FIRST = 300;
30:
31: public static final int CONTAINER_LAST = 301;
32:
33: public static final int COMPONENT_ADDED = 300;
34:
35: public static final int COMPONENT_REMOVED = 301;
36:
37: private Component child;
38:
39: public ContainerEvent(Component src, int id, Component child) {
40: super (src, id);
41: this .child = child;
42: }
43:
44: public Component getChild() {
45: return child;
46: }
47:
48: public Container getContainer() {
49: return (Container) source;
50: }
51:
52: @Override
53: public String paramString() {
54: /* The format is based on 1.5 release behavior
55: * which can be revealed by the following code:
56: *
57: * ContainerEvent e = new ContainerEvent(new Panel(),
58: * ContainerEvent.COMPONENT_ADDED,
59: * new Button("Button"));
60: * System.out.println(e);
61: */
62:
63: String idString = null;
64:
65: switch (id) {
66: case COMPONENT_ADDED:
67: idString = "COMPONENT_ADDED"; //$NON-NLS-1$
68: break;
69: case COMPONENT_REMOVED:
70: idString = "COMPONENT_REMOVED"; //$NON-NLS-1$
71: break;
72: default:
73: idString = "unknown type"; //$NON-NLS-1$
74: }
75:
76: return (idString + ",child=" + child.getName()); //$NON-NLS-1$
77: }
78:
79: }
|