1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     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 */
21package java.awt.event;
22
23import java.awt.AWTEvent;
24import java.awt.Component;
25
26/**
27 * This class is not supported in Android 1.0. It is merely provided to maintain
28 * interface compatibility with desktop Java implementations.
29 *
30 * @since Android 1.0
31 */
32public class ComponentEvent extends AWTEvent {
33
34    private static final long serialVersionUID = 8101406823902992965L;
35
36    public static final int COMPONENT_FIRST = 100;
37
38    public static final int COMPONENT_LAST = 103;
39
40    public static final int COMPONENT_MOVED = 100;
41
42    public static final int COMPONENT_RESIZED = 101;
43
44    public static final int COMPONENT_SHOWN = 102;
45
46    public static final int COMPONENT_HIDDEN = 103;
47
48    public ComponentEvent(Component source, int id) {
49        super(source, id);
50    }
51
52    public Component getComponent() {
53        return (Component) source;
54    }
55
56    @Override
57    public String paramString() {
58        /* The format is based on 1.5 release behavior
59         * which can be revealed by the following code:
60         *
61         * ComponentEvent e = new ComponentEvent(new Button("Button"),
62         *          ComponentEvent.COMPONENT_SHOWN);
63         * System.out.println(e);
64         */
65
66        String idString = null;
67        Component c = getComponent();
68
69        switch (id) {
70        case COMPONENT_MOVED:
71            idString = "COMPONENT_MOVED"; //$NON-NLS-1$
72            break;
73        case COMPONENT_RESIZED:
74            idString = "COMPONENT_RESIZED"; //$NON-NLS-1$
75            break;
76        case COMPONENT_SHOWN:
77            return "COMPONENT_SHOWN"; //$NON-NLS-1$
78        case COMPONENT_HIDDEN:
79            return "COMPONENT_HIDDEN"; //$NON-NLS-1$
80        default:
81            return "unknown type"; //$NON-NLS-1$
82        }
83
84        return (idString + " (" + c.getX() + "," + c.getY() +  //$NON-NLS-1$ //$NON-NLS-2$
85                " " + c.getWidth()+ "x" + c.getHeight() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
86    }
87
88}
89