KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > events > TypedEvent


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.events;
12
13
14 import org.eclipse.swt.widgets.*;
15 import org.eclipse.swt.internal.SWTEventObject;
16
17 /**
18  * This is the super class for all typed event classes provided
19  * by SWT. Typed events contain particular information which is
20  * applicable to the event occurrence.
21  *
22  * @see org.eclipse.swt.widgets.Event
23  */

24 public class TypedEvent extends SWTEventObject {
25     
26     /**
27      * the display where the event occurred
28      *
29      * @since 2.0
30      */

31     public Display display;
32         
33     /**
34      * the widget that issued the event
35      */

36     public Widget widget;
37     
38     /**
39      * the time that the event occurred.
40      *
41      * NOTE: This field is an unsigned integer and should
42      * be AND'ed with 0xFFFFFFFFL so that it can be treated
43      * as a signed long.
44      */

45     public int time;
46     
47     /**
48      * a field for application use
49      */

50     public Object JavaDoc data;
51
52     static final long serialVersionUID = 3257285846578377524L;
53     
54 /**
55  * Constructs a new instance of this class.
56  *
57  * @param object the object that fired the event
58  */

59 public TypedEvent(Object JavaDoc object) {
60     super(object);
61 }
62
63 /**
64  * Constructs a new instance of this class based on the
65  * information in the argument.
66  *
67  * @param e the low level event to initialize the receiver with
68  */

69 public TypedEvent(Event e) {
70     super(e.widget);
71     this.display = e.display;
72     this.widget = e.widget;
73     this.time = e.time;
74     this.data = e.data;
75 }
76
77 /**
78  * Returns the name of the event. This is the name of
79  * the class without the package name.
80  *
81  * @return the name of the event
82  */

83 String JavaDoc getName () {
84     String JavaDoc string = getClass ().getName ();
85     int index = string.lastIndexOf ('.');
86     if (index == -1) return string;
87     return string.substring (index + 1, string.length ());
88 }
89
90 /**
91  * Returns a string containing a concise, human-readable
92  * description of the receiver.
93  *
94  * @return a string representation of the event
95  */

96 public String JavaDoc toString() {
97     return getName ()
98         + "{" + widget
99         + " time=" + time
100         + " data=" + data
101         + "}";
102 }
103 }
104
Popular Tags