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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @author Michael Danilov
21 package java.awt.event;
23 import java.awt.AWTEvent;
24 import java.awt.Component;
25 //???AWT: import java.awt.Container;
28 * This class is not supported in Android 1.0. It is merely provided to maintain
29 * interface compatibility with desktop Java implementations.
33 public class HierarchyEvent extends AWTEvent {
35 private static final long serialVersionUID = -5337576970038043990L;
37 public static final int HIERARCHY_FIRST = 1400;
39 public static final int HIERARCHY_CHANGED = 1400;
41 public static final int ANCESTOR_MOVED = 1401;
43 public static final int ANCESTOR_RESIZED = 1402;
45 public static final int HIERARCHY_LAST = 1402;
47 public static final int PARENT_CHANGED = 1;
49 public static final int DISPLAYABILITY_CHANGED = 2;
51 public static final int SHOWING_CHANGED = 4;
53 //???AWT: private Container changedParent;
54 private Component changed;
55 private long changeFlag;
59 public HierarchyEvent(Component source, int id, Component changed,
60 Container changedParent) {
61 this(source, id, changed, changedParent, 0l);
67 public HierarchyEvent(Component source, int id, Component changed,
68 Container changedParent, long changeFlags) {
71 this.changed = changed;
72 this.changedParent = changedParent;
73 this.changeFlag = changeFlags;
76 //???AWT: Fake constructor, should be as above.
77 public HierarchyEvent(Component source, int id, Component changed,
78 Object changedParent, long changeFlags) {
81 // this.changed = changed;
82 // this.changedParent = changedParent;
83 // this.changeFlag = changeFlags;
86 public Component getComponent() {
87 return (Component) source;
90 public long getChangeFlags() {
94 public Component getChanged() {
100 public Container getChangedParent() {
101 return changedParent;
107 public String paramString() {
108 /* The format is based on 1.5 release behavior
109 * which can be revealed by the following code:
111 * HierarchyEvent e = new HierarchyEvent(new Button("Button"),
112 * HierarchyEvent.HIERARCHY_CHANGED,
113 * new Panel(), new Container());
114 * System.out.println(e);
116 String paramString = null;
119 case HIERARCHY_CHANGED:
120 paramString = "HIERARCHY_CHANGED"; //$NON-NLS-1$
123 paramString = "ANCESTOR_MOVED"; //$NON-NLS-1$
125 case ANCESTOR_RESIZED:
126 paramString = "ANCESTOR_RESIZED"; //$NON-NLS-1$
129 paramString = "unknown type"; //$NON-NLS-1$
132 paramString += " ("; //$NON-NLS-1$
134 if (id == HIERARCHY_CHANGED) {
135 if ((changeFlag & PARENT_CHANGED) > 0) {
136 paramString += "PARENT_CHANGED,"; //$NON-NLS-1$
138 if ((changeFlag & DISPLAYABILITY_CHANGED) > 0) {
139 paramString += "DISPLAYABILITY_CHANGED,"; //$NON-NLS-1$
141 if ((changeFlag & SHOWING_CHANGED) > 0) {
142 paramString += "SHOWING_CHANGED,"; //$NON-NLS-1$
148 return paramString + "changed=" + changed + //$NON-NLS-1$
149 ",changedParent=" + changedParent + ")"; //$NON-NLS-1$ //$NON-NLS-2$