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.AWTEvent;
23: import java.awt.Component;
24:
25: public class ComponentEvent extends AWTEvent {
26:
27: private static final long serialVersionUID = 8101406823902992965L;
28:
29: public static final int COMPONENT_FIRST = 100;
30:
31: public static final int COMPONENT_LAST = 103;
32:
33: public static final int COMPONENT_MOVED = 100;
34:
35: public static final int COMPONENT_RESIZED = 101;
36:
37: public static final int COMPONENT_SHOWN = 102;
38:
39: public static final int COMPONENT_HIDDEN = 103;
40:
41: public ComponentEvent(Component source, int id) {
42: super (source, id);
43: }
44:
45: public Component getComponent() {
46: return (Component) source;
47: }
48:
49: @Override
50: public String paramString() {
51: /* The format is based on 1.5 release behavior
52: * which can be revealed by the following code:
53: *
54: * ComponentEvent e = new ComponentEvent(new Button("Button"),
55: * ComponentEvent.COMPONENT_SHOWN);
56: * System.out.println(e);
57: */
58:
59: String idString = null;
60: Component c = getComponent();
61:
62: switch (id) {
63: case COMPONENT_MOVED:
64: idString = "COMPONENT_MOVED"; //$NON-NLS-1$
65: break;
66: case COMPONENT_RESIZED:
67: idString = "COMPONENT_RESIZED"; //$NON-NLS-1$
68: break;
69: case COMPONENT_SHOWN:
70: return "COMPONENT_SHOWN"; //$NON-NLS-1$
71: case COMPONENT_HIDDEN:
72: return "COMPONENT_HIDDEN"; //$NON-NLS-1$
73: default:
74: return "unknown type"; //$NON-NLS-1$
75: }
76:
77: return (idString + " (" + c.getX() + "," + c.getY() + //$NON-NLS-1$ //$NON-NLS-2$
78: " " + c.getWidth() + "x" + c.getHeight() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
79: }
80:
81: }
|