• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
21 package java.awt.event;
22 
23 import java.awt.Component;
24 
25 /**
26  * This class is not supported in Android 1.0. It is merely provided to maintain
27  * interface compatibility with desktop Java implementations.
28  *
29  * @since Android 1.0
30  */
31 public class FocusEvent extends ComponentEvent {
32 
33     private static final long serialVersionUID = 523753786457416396L;
34 
35     public static final int FOCUS_FIRST = 1004;
36 
37     public static final int FOCUS_LAST = 1005;
38 
39     public static final int FOCUS_GAINED = 1004;
40 
41     public static final int FOCUS_LOST = 1005;
42 
43     private boolean temporary;
44     private Component opposite;
45 
FocusEvent(Component source, int id)46     public FocusEvent(Component source, int id) {
47         this(source, id, false);
48     }
49 
FocusEvent(Component source, int id, boolean temporary)50     public FocusEvent(Component source, int id, boolean temporary) {
51         this(source, id, temporary, null);
52     }
53 
FocusEvent(Component source, int id, boolean temporary, Component opposite)54     public FocusEvent(Component source, int id, boolean temporary, Component opposite) {
55         super(source, id);
56         this.temporary = temporary;
57         this.opposite = opposite;
58     }
59 
getOppositeComponent()60     public Component getOppositeComponent() {
61         return opposite;
62     }
63 
isTemporary()64     public boolean isTemporary() {
65         return temporary;
66     }
67 
68     @Override
paramString()69     public String paramString() {
70         /* The format is based on 1.5 release behavior
71          * which can be revealed by the following code:
72          *
73          * FocusEvent e = new FocusEvent(new Button("Button0"),
74          *       FocusEvent.FOCUS_GAINED, false, new Button("Button1"));
75          * System.out.println(e);
76          */
77 
78         String idString = null;
79 
80         switch (id) {
81         case FOCUS_GAINED:
82             idString = "FOCUS_GAINED"; //$NON-NLS-1$
83             break;
84         case FOCUS_LOST:
85             idString = "FOCUS_LOST"; //$NON-NLS-1$
86             break;
87         default:
88             idString = "unknown type"; //$NON-NLS-1$
89         }
90 
91         return (idString +
92                 (temporary ? ",temporary" : ",permanent") + //$NON-NLS-1$ //$NON-NLS-2$
93                 ",opposite=" + opposite); //$NON-NLS-1$
94     }
95 
96 }
97