Source Code Cross Referenced for Event.java in  » 6.0-JDK-Modules » j2me » java » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)Event.java	1.66 06/10/10
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation. 
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt). 
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA 
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions. 
025:         *
026:         */
027:        package java.awt;
028:
029:        import java.awt.event.*;
030:        import java.io.*;
031:
032:        /**
033:         * <code>Event</code> is a platform-independent class that  
034:         * encapsulates events from the platform's Graphical User 
035:         * Interface in the Java&nbsp;1.0 event model. In Java&nbsp;1.1 
036:         * and later versions, the <code>Event</code> class is maintained 
037:         * only for backwards compatibilty. The information in this
038:         * class description is provided to assist programmers in
039:         * converting Java&nbsp;1.0 programs to the new event model.
040:         * <p>
041:         * In the Java&nbsp;1.0 event model, an event contains an 
042:         * <a href="#id"><code>id</code></a> field 
043:         * that indicates what type of event it is and which other 
044:         * <code>Event</code> variables are relevant for the event.
045:         * <p>
046:         * For keyboard events, <a href="#key"><code>key</code></a> 
047:         * contains a value indicating which key was activated, and 
048:         * <a href="#modifiers"><code>modifiers</code></a> contains the 
049:         * modifiers for that event.  For the KEY_PRESS and KEY_RELEASE  
050:         * event ids, the value of <code>key</code> is the unicode 
051:         * character code for the key. For KEY_ACTION and 
052:         * KEY_ACTION_RELEASE, the value of <code>key</code> is
053:         * one of the defined action-key identifiers in the 
054:         * <code>Event</code> class (<code>PGUP</code>,  
055:         * <code>PGDN</code>, <code>F1</code>, <code>F2</code>, etc).
056:         *
057:         * @version 1.62 08/19/02
058:         * @author     Sami Shaio
059:         * @since      JDK1.0
060:         */
061:        public class Event implements  java.io.Serializable {
062:            private transient int data;
063:            /* Modifier constants */
064:
065:            /**
066:             * This flag indicates that the Shift key was down when the event 
067:             * occurred. 
068:             * @since   JDK1.0
069:             */
070:            public static final int SHIFT_MASK = 1 << 0;
071:            /**
072:             * This flag indicates that the Control key was down when the event 
073:             * occurred. 
074:             * @since   JDK1.0
075:             */
076:            public static final int CTRL_MASK = 1 << 1;
077:            /** 
078:             * This flag indicates that the Meta key was down when the event 
079:             * occurred. For mouse events, this flag indicates that the right 
080:             * button was pressed or released. 
081:             * @since    JDK1.0
082:             */
083:            public static final int META_MASK = 1 << 2;
084:            /** 
085:             * This flag indicates that the Alt key was down when 
086:             * the event occurred. For mouse events, this flag indicates that the 
087:             * middle mouse button was pressed or released. 
088:             * @since   JDK1.0
089:             */
090:            public static final int ALT_MASK = 1 << 3;
091:            /* Action keys */
092:
093:            /** 
094:             * The Home key, a non-ASCII action key. 
095:             * @since   JDK1.0
096:             */
097:            public static final int HOME = 1000;
098:            /** 
099:             * The End key, a non-ASCII action key. 
100:             * @since   JDK1.0
101:             */
102:            public static final int END = 1001;
103:            /**
104:             * The Page Up key, a non-ASCII action key. 
105:             * @since   JDK1.0
106:             */
107:            public static final int PGUP = 1002;
108:            /**
109:             * The Page Down key, a non-ASCII action key. 
110:             * @since   JDK1.0
111:             */
112:            public static final int PGDN = 1003;
113:            /**
114:             * The Up Arrow key, a non-ASCII action key. 
115:             * @since   JDK1.0
116:             */
117:            public static final int UP = 1004;
118:            /**
119:             * The Down Arrow key, a non-ASCII action key. 
120:             * @since   JDK1.0
121:             */
122:            public static final int DOWN = 1005;
123:            /**
124:             * The Left Arrow key, a non-ASCII action key. 
125:             * @since   JDK1.0
126:             */
127:            public static final int LEFT = 1006;
128:            /**
129:             * The Right Arrow key, a non-ASCII action key. 
130:             * @since   JDK1.0
131:             */
132:            public static final int RIGHT = 1007;
133:            /**
134:             * The F1 function key, a non-ASCII action key.
135:             * @since   JDK1.0
136:             */
137:            public static final int F1 = 1008;
138:            /**
139:             * The F2 function key, a non-ASCII action key.
140:             * @since   JDK1.0
141:             */
142:            public static final int F2 = 1009;
143:            /**
144:             * The F3 function key, a non-ASCII action key.
145:             * @since   JDK1.0
146:             */
147:            public static final int F3 = 1010;
148:            /**
149:             * The F4 function key, a non-ASCII action key.
150:             * @since   JDK1.0
151:             */
152:            public static final int F4 = 1011;
153:            /**
154:             * The F5 function key, a non-ASCII action key.
155:             * @since   JDK1.0
156:             */
157:            public static final int F5 = 1012;
158:            /**
159:             * The F6 function key, a non-ASCII action key.
160:             * @since   JDK1.0
161:             */
162:            public static final int F6 = 1013;
163:            /**
164:             * The F7 function key, a non-ASCII action key.
165:             * @since   JDK1.0
166:             */
167:            public static final int F7 = 1014;
168:            /**
169:             * The F8 function key, a non-ASCII action key.
170:             * @since   JDK1.0
171:             */
172:            public static final int F8 = 1015;
173:            /**
174:             * The F9 function key, a non-ASCII action key.
175:             * @since   JDK1.0
176:             */
177:            public static final int F9 = 1016;
178:            /**
179:             * The F10 function key, a non-ASCII action key.
180:             * @since   JDK1.0
181:             */
182:            public static final int F10 = 1017;
183:            /**
184:             * The F11 function key, a non-ASCII action key.
185:             * @since   JDK1.0
186:             */
187:            public static final int F11 = 1018;
188:            /**
189:             * The F12 function key, a non-ASCII action key.
190:             * @since   JDK1.0
191:             */
192:            public static final int F12 = 1019;
193:            /**
194:             * The Print Screen key, a non-ASCII action key.
195:             * @since   JDK1.0
196:             */
197:            public static final int PRINT_SCREEN = 1020;
198:            /**
199:             * The Scroll Lock key, a non-ASCII action key.
200:             * @since   JDK1.0
201:             */
202:            public static final int SCROLL_LOCK = 1021;
203:            /**
204:             * The Caps Lock key, a non-ASCII action key.
205:             * @since   JDK1.0
206:             */
207:            public static final int CAPS_LOCK = 1022;
208:            /**
209:             * The Num Lock key, a non-ASCII action key.
210:             * @since   JDK1.0
211:             */
212:            public static final int NUM_LOCK = 1023;
213:            /**
214:             * The Pause key, a non-ASCII action key.
215:             * @since   JDK1.0
216:             */
217:            public static final int PAUSE = 1024;
218:            /**
219:             * The Insert key, a non-ASCII action key.
220:             * @since   JDK1.0
221:             */
222:            public static final int INSERT = 1025;
223:            /* Non-action keys */
224:
225:            /**
226:             * The Enter key.
227:             * @since   JDK1.0
228:             */
229:            public static final int ENTER = '\n';
230:            /**
231:             * The BackSpace key.
232:             * @since   JDK1.0
233:             */
234:            public static final int BACK_SPACE = '\b';
235:            /**
236:             * The Tab key.
237:             * @since   JDK1.0
238:             */
239:            public static final int TAB = '\t';
240:            /**
241:             * The Escape key.
242:             * @since   JDK1.0
243:             */
244:            public static final int ESCAPE = 27;
245:            /**
246:             * The Delete key.
247:             * @since   JDK1.0
248:             */
249:            public static final int DELETE = 127;
250:            /* Base for all window events. */
251:            private static final int WINDOW_EVENT = 200;
252:            /**
253:             * The user has asked the window manager to kill the window.
254:             * @since    JDK1.0
255:             */
256:            public static final int WINDOW_DESTROY = 1 + WINDOW_EVENT;
257:            /**
258:             * The user has asked the window manager to expose the window.
259:             * @since    JDK1.0
260:             */
261:            public static final int WINDOW_EXPOSE = 2 + WINDOW_EVENT;
262:            /** 
263:             * The user has asked the window manager to iconify the window.
264:             * @since    JDK1.0
265:             */
266:            public static final int WINDOW_ICONIFY = 3 + WINDOW_EVENT;
267:            /** 
268:             * The user has asked the window manager to de-iconify the window.
269:             * @since    JDK1.0
270:             */
271:            public static final int WINDOW_DEICONIFY = 4 + WINDOW_EVENT;
272:            /**
273:             * The user has asked the window manager to move the window.
274:             * @since    JDK1.0
275:             */
276:            public static final int WINDOW_MOVED = 5 + WINDOW_EVENT;
277:            /* Base for all keyboard events. */
278:            private static final int KEY_EVENT = 400;
279:            /**
280:             * The user has pressed a normal key.  
281:             * @since   JDK1.0
282:             */
283:            public static final int KEY_PRESS = 1 + KEY_EVENT;
284:            /**
285:             * The user has released a normal key.  
286:             * @since   JDK1.0
287:             */
288:            public static final int KEY_RELEASE = 2 + KEY_EVENT;
289:            /** 
290:             * The user has pressed a non-ASCII <em>action</em> key.  
291:             * The <code>key</code> field contains a value that indicates
292:             * that the event occurred on one of the action keys, which
293:             * comprise the 12 function keys, the arrow (cursor) keys,
294:             * Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
295:             * Caps Lock, Num Lock, Pause, and Insert.
296:             * @since   JDK1.0
297:             */
298:            public static final int KEY_ACTION = 3 + KEY_EVENT;
299:            /** 
300:             * The user has released a non-ASCII <em>action</em> key.  
301:             * The <code>key</code> field contains a value that indicates
302:             * that the event occurred on one of the action keys, which
303:             * comprise the 12 function keys, the arrow (cursor) keys,
304:             * Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
305:             * Caps Lock, Num Lock, Pause, and Insert.
306:             * @since   JDK1.0
307:             */
308:            public static final int KEY_ACTION_RELEASE = 4 + KEY_EVENT;
309:            /* Base for all mouse events. */
310:            private static final int MOUSE_EVENT = 500;
311:            /**
312:             * The user has pressed the mouse button. The <code>ALT_MASK</code> 
313:             * flag indicates that the middle button has been pressed. 
314:             * The <code>META_MASK</code>flag indicates that the 
315:             * right button has been pressed. 
316:             * @see     java.awt.Event#ALT_MASK
317:             * @see     java.awt.Event#META_MASK
318:             * @since   JDK1.0
319:             */
320:            public static final int MOUSE_DOWN = 1 + MOUSE_EVENT;
321:            /**
322:             * The user has released the mouse button. The <code>ALT_MASK</code> 
323:             * flag indicates that the middle button has been released. 
324:             * The <code>META_MASK</code>flag indicates that the 
325:             * right button has been released. 
326:             * @see     java.awt.Event#ALT_MASK
327:             * @see     java.awt.Event#META_MASK
328:             * @since   JDK1.0
329:             */
330:            public static final int MOUSE_UP = 2 + MOUSE_EVENT;
331:            /**
332:             * The mouse has moved with no button pressed. 
333:             * @since   JDK1.0
334:             */
335:            public static final int MOUSE_MOVE = 3 + MOUSE_EVENT;
336:            /**
337:             * The mouse has entered a component. 
338:             * @since   JDK1.0
339:             */
340:            public static final int MOUSE_ENTER = 4 + MOUSE_EVENT;
341:            /**
342:             * The mouse has exited a component. 
343:             * @since   JDK1.0
344:             */
345:            public static final int MOUSE_EXIT = 5 + MOUSE_EVENT;
346:            /** 
347:             * The user has moved the mouse with a button pressed. The 
348:             * <code>ALT_MASK</code> flag indicates that the middle 
349:             * button is being pressed. The <code>META_MASK</code> flag indicates 
350:             * that the right button is being pressed. 
351:             * @see     java.awt.Event#ALT_MASK
352:             * @see     java.awt.Event#META_MASK
353:             * @since   JDK1.0
354:             */
355:            public static final int MOUSE_DRAG = 6 + MOUSE_EVENT;
356:            /* Scrolling events */
357:            private static final int SCROLL_EVENT = 600;
358:            /** 
359:             * The user has activated the <em>line up</em>  
360:             * area of a scroll bar. 
361:             * @since   JDK1.0
362:             */
363:            public static final int SCROLL_LINE_UP = 1 + SCROLL_EVENT;
364:            /**
365:             * The user has activated the <em>line down</em>  
366:             * area of a scroll bar. 
367:             * @since   JDK1.0
368:             */
369:            public static final int SCROLL_LINE_DOWN = 2 + SCROLL_EVENT;
370:            /**
371:             * The user has activated the <em>page up</em>  
372:             * area of a scroll bar. 
373:             * @since   JDK1.0
374:             */
375:            public static final int SCROLL_PAGE_UP = 3 + SCROLL_EVENT;
376:            /**
377:             * The user has activated the <em>page down</em>  
378:             * area of a scroll bar. 
379:             * @since   JDK1.0
380:             */
381:            public static final int SCROLL_PAGE_DOWN = 4 + SCROLL_EVENT;
382:            /**
383:             * The user has moved the bubble (thumb) in a scroll bar,
384:             * moving to an "absolute" position, rather than to
385:             * an offset from the last postion.
386:             * @since   JDK1.0
387:             */
388:            public static final int SCROLL_ABSOLUTE = 5 + SCROLL_EVENT;
389:            /**
390:             * The scroll begin event.
391:             * @since   JDK1.0
392:             */
393:            public static final int SCROLL_BEGIN = 6 + SCROLL_EVENT;
394:            /**
395:             * The scroll end event.
396:             * @since   JDK1.0
397:             */
398:            public static final int SCROLL_END = 7 + SCROLL_EVENT;
399:            /* List Events */
400:            private static final int LIST_EVENT = 700;
401:            /**
402:             * An item in a list has been selected. 
403:             * @since   JDK1.0
404:             */
405:            public static final int LIST_SELECT = 1 + LIST_EVENT;
406:            /**
407:             * An item in a list has been deselected. 
408:             * @since   JDK1.0
409:             */
410:            public static final int LIST_DESELECT = 2 + LIST_EVENT;
411:            /* Misc Event */
412:            private static final int MISC_EVENT = 1000;
413:            /**
414:             * This event indicates that the user wants some action to occur. 
415:             * @since   JDK1.0
416:             */
417:            public static final int ACTION_EVENT = 1 + MISC_EVENT;
418:            /**
419:             * A file loading event.
420:             * @since   JDK1.0
421:             */
422:            public static final int LOAD_FILE = 2 + MISC_EVENT;
423:            /**
424:             * A file saving event.
425:             * @since   JDK1.0
426:             */
427:            public static final int SAVE_FILE = 3 + MISC_EVENT;
428:            /**
429:             * A component gained the focus.
430:             * @since   JDK1.0
431:             */
432:            public static final int GOT_FOCUS = 4 + MISC_EVENT;
433:            /**
434:             * A component lost the focus.
435:             * @since   JDK1.0
436:             */
437:            public static final int LOST_FOCUS = 5 + MISC_EVENT;
438:            /**
439:             * The target component. This indicates the component over which the 
440:             * event occurred or with which the event is associated. 
441:             * @since   JDK1.0
442:             */
443:            public Object target;
444:            /**
445:             * The time stamp.
446:             * @since   JDK1.0
447:             */
448:            public long when;
449:            /**
450:             * Indicates which type of event the event is, and which 
451:             * other <code>Event</code> variables are relevant for the event.
452:             * @since   JDK1.0
453:             */
454:            public int id;
455:            /** 
456:             * The <i>x</i> coordinate of the event. 
457:             * @since   JDK1.0
458:             */
459:            public int x;
460:            /** 
461:             * The <i>y</i> coordinate of the event. 
462:             * @since   JDK1.0
463:             */
464:            public int y;
465:            /** 
466:             * The key code of the key that was pressed in a keyboard event. 
467:             * @since   JDK1.0
468:             */
469:            public int key;
470:            /** 
471:             * The key character that was pressed in a keyboard event. 
472:             * @since   JDK1.0
473:             */
474:            //    public char keyChar;
475:            /** 
476:             * The state of the modifier keys.
477:             * <p>
478:             * NOTE:  changing the modifier keys is not recommended, because many
479:             * native implementations do not recognize modifier changes.  This is
480:             * especially true when the shift modifier is changed.
481:             *
482:             * @since     JDK1.0
483:             */
484:            public int modifiers;
485:            /**
486:             * For <code>MOUSE_DOWN</code> events, this field indicates the 
487:             * number of consecutive clicks. For other events, its value is 
488:             * <code>0</code>. 
489:             * @since   JDK1.0
490:             */
491:            public int clickCount;
492:            /**
493:             * An arbitrary argument of the event. The value of this field 
494:             * depends on the type of event. 
495:             * @since   JDK1.0
496:             */
497:            public Object arg;
498:            /**
499:             * The next event. This field is set when putting events into a 
500:             * linked list. 
501:             * @since   JDK1.0
502:             */
503:            public Event evt;
504:            /* table for mapping old Event action keys to KeyEvent virtual keys. */
505:            private static final int actionKeyCodes[][] = {
506:
507:            /*    virtual key              action key   */
508:            { KeyEvent.VK_HOME, Event.HOME }, { KeyEvent.VK_END, Event.END },
509:                    { KeyEvent.VK_PAGE_UP, Event.PGUP },
510:                    { KeyEvent.VK_PAGE_DOWN, Event.PGDN },
511:                    { KeyEvent.VK_UP, Event.UP },
512:                    { KeyEvent.VK_DOWN, Event.DOWN },
513:                    { KeyEvent.VK_LEFT, Event.LEFT },
514:                    { KeyEvent.VK_RIGHT, Event.RIGHT },
515:                    { KeyEvent.VK_F1, Event.F1 }, { KeyEvent.VK_F2, Event.F2 },
516:                    { KeyEvent.VK_F3, Event.F3 }, { KeyEvent.VK_F4, Event.F4 },
517:                    { KeyEvent.VK_F5, Event.F5 }, { KeyEvent.VK_F6, Event.F6 },
518:                    { KeyEvent.VK_F7, Event.F7 }, { KeyEvent.VK_F8, Event.F8 },
519:                    { KeyEvent.VK_F9, Event.F9 },
520:                    { KeyEvent.VK_F10, Event.F10 },
521:                    { KeyEvent.VK_F11, Event.F11 },
522:                    { KeyEvent.VK_F12, Event.F12 },
523:                    { KeyEvent.VK_PRINTSCREEN, Event.PRINT_SCREEN },
524:                    { KeyEvent.VK_SCROLL_LOCK, Event.SCROLL_LOCK },
525:                    { KeyEvent.VK_CAPS_LOCK, Event.CAPS_LOCK },
526:                    { KeyEvent.VK_NUM_LOCK, Event.NUM_LOCK },
527:                    { KeyEvent.VK_PAUSE, Event.PAUSE },
528:                    { KeyEvent.VK_INSERT, Event.INSERT } };
529:            // This field controls whether or not the event is sent back
530:            // down to the peer once the target has processed it -
531:            // false means it's sent to the peer, true means it's not.
532:            private boolean consumed = false;
533:            /*
534:             * JDK 1.1 serialVersionUID 
535:             */
536:            private static final long serialVersionUID = 5488922509400504703L;
537:
538:            /**
539:             * Creates an instance of <code>Event</code> with the specified target 
540:             * component, time stamp, event type, <i>x</i> and <i>y</i> 
541:             * coordinates, keyboard key, state of the modifier keys, and 
542:             * argument. 
543:             * @param     target     the target component.
544:             * @param     when       the time stamp.
545:             * @param     id         the event type.
546:             * @param     x          the <i>x</i> coordinate.
547:             * @param     y          the <i>y</i> coordinate.
548:             * @param     key        the key pressed in a keyboard event.
549:             * @param     modifiers  the state of the modifier keys.
550:             * @param     arg        the specified argument.
551:             * @since     JDK1.0
552:             */
553:            public Event(Object target, long when, int id, int x, int y,
554:                    int key, int modifiers, Object arg) {
555:                this .target = target;
556:                this .when = when;
557:                this .id = id;
558:                this .x = x;
559:                this .y = y;
560:                this .key = key;
561:                this .modifiers = modifiers;
562:                this .arg = arg;
563:                this .data = 0;
564:                this .clickCount = 0;
565:                switch (id) {
566:                case ACTION_EVENT:
567:                case WINDOW_DESTROY:
568:                case WINDOW_ICONIFY:
569:                case WINDOW_DEICONIFY:
570:                case WINDOW_MOVED:
571:                case SCROLL_LINE_UP:
572:                case SCROLL_LINE_DOWN:
573:                case SCROLL_PAGE_UP:
574:                case SCROLL_PAGE_DOWN:
575:                case SCROLL_ABSOLUTE:
576:                case SCROLL_BEGIN:
577:                case SCROLL_END:
578:                case LIST_SELECT:
579:                case LIST_DESELECT:
580:                    consumed = true; // these types are not passed back to peer
581:                    break;
582:
583:                default:
584:                }
585:            }
586:
587:            /**
588:             * Creates an instance of <code>Event</code>, with the specified target 
589:             * component, time stamp, event type, <i>x</i> and <i>y</i> 
590:             * coordinates, keyboard key, state of the modifier keys, and an 
591:             * argument set to <code>null</code>. 
592:             * @param     target     the target component.
593:             * @param     when       the time stamp.
594:             * @param     id         the event type.
595:             * @param     x          the <i>x</i> coordinate.
596:             * @param     y          the <i>y</i> coordinate.
597:             * @param     key        the key pressed in a keyboard event.
598:             * @param     modifiers  the state of the modifier keys.
599:             * @since    JDK1.0
600:             */
601:            public Event(Object target, long when, int id, int x, int y,
602:                    int key, int modifiers) {
603:                this (target, when, id, x, y, key, modifiers, null);
604:            }
605:
606:            /**
607:             * Creates an instance of <code>Event</code> with the specified  
608:             * target component, event type, and argument. 
609:             * @param     target     the target component.
610:             * @param     id         the event type.
611:             * @param     arg        the specified argument.
612:             * @since     JDK1.0
613:             */
614:            public Event(Object target, int id, Object arg) {
615:                this (target, 0, id, 0, 0, 0, 0, arg);
616:            }
617:
618:            /** 
619:             * Translates this event so that its <i>x</i> and <i>y</i> 
620:             * coordinates are increased by <i>dx</i> and <i>dy</i>, 
621:             * respectively. 
622:             * <p>
623:             * This method translates an event relative to the given component. 
624:             * This involves, at a minimum, translating the coordinates into the
625:             * local coordinate system of the given component. It may also involve
626:             * translating a region in the case of an expose event.
627:             * @param     dx     the distance to translate the <i>x</i> coordinate.
628:             * @param     dy     the distance to translate the <i>y</i> coordinate.
629:             * @since     JDK1.0
630:             */
631:            public void translate(int x, int y) {
632:                this .x += x;
633:                this .y += y;
634:            }
635:
636:            /**
637:             * Checks if the Shift key is down.
638:             * @return    <code>true</code> if the key is down; 
639:             *            <code>false</code> otherwise.
640:             * @see       java.awt.Event#modifiers
641:             * @see       java.awt.Event#controlDown
642:             * @see       java.awt.Event#metaDown
643:             * @since     JDK1.0
644:             */
645:            public boolean shiftDown() {
646:                return (modifiers & SHIFT_MASK) != 0;
647:            }
648:
649:            /**
650:             * Checks if the Control key is down.
651:             * @return    <code>true</code> if the key is down; 
652:             *            <code>false</code> otherwise.
653:             * @see       java.awt.Event#modifiers
654:             * @see       java.awt.Event#shiftDown
655:             * @see       java.awt.Event#metaDown
656:             * @since     JDK1.0
657:             */
658:            public boolean controlDown() {
659:                return (modifiers & CTRL_MASK) != 0;
660:            }
661:
662:            /**
663:             * Checks if the Meta key is down.
664:             * @return    <code>true</code> if the key is down; 
665:             *            <code>false</code> otherwise.
666:             * @see       java.awt.Event#modifiers
667:             * @see       java.awt.Event#shiftDown
668:             * @see       java.awt.Event#controlDown
669:             * @since     JDK1.0
670:             */
671:            public boolean metaDown() {
672:                return (modifiers & META_MASK) != 0;
673:            }
674:
675:            void consume() {
676:                switch (id) {
677:                case KEY_PRESS:
678:                case KEY_RELEASE:
679:                case KEY_ACTION:
680:                case KEY_ACTION_RELEASE:
681:                    consumed = true;
682:                    break;
683:
684:                default:
685:                    // event type cannot be consumed
686:                }
687:            }
688:
689:            boolean isConsumed() {
690:                return consumed;
691:            }
692:
693:            /*
694:             * Returns the integer key-code associated with the key in this event,
695:             * as described in java.awt.Event.  
696:             */
697:            static int getOldEventKey(KeyEvent e) {
698:                int keyCode = e.getKeyCode();
699:                for (int i = 0; i < actionKeyCodes.length; i++) {
700:                    if (actionKeyCodes[i][0] == keyCode) {
701:                        return actionKeyCodes[i][1];
702:                    }
703:                }
704:                return (int) e.getKeyChar();
705:            }
706:
707:            /*
708:             * Returns a new KeyEvent char which corresponds to the int key
709:             * of this old event.
710:             */
711:            char getKeyEventChar() {
712:                for (int i = 0; i < actionKeyCodes.length; i++) {
713:                    if (actionKeyCodes[i][1] == key) {
714:                        return KeyEvent.CHAR_UNDEFINED;
715:                    }
716:                }
717:                return (char) key;
718:            }
719:
720:            /**
721:             * Returns the parameter string representing this event. 
722:             * This string is useful for debugging.
723:             * @return    the parameter string of this event.
724:             * @since     JDK1.0 
725:             */
726:            protected String paramString() {
727:                String str = "id=" + id + ",x=" + x + ",y=" + y;
728:                if (key != 0) {
729:                    str += ",key=" + key;
730:                }
731:                if (shiftDown()) {
732:                    str += ",shift";
733:                }
734:                if (controlDown()) {
735:                    str += ",control";
736:                }
737:                if (metaDown()) {
738:                    str += ",meta";
739:                }
740:                if (target != null) {
741:                    str += ",target=" + target;
742:                }
743:                if (arg != null) {
744:                    str += ",arg=" + arg;
745:                }
746:                return str;
747:            }
748:
749:            /**
750:             * Returns a representation of this event's values as a string.
751:             * @return    a string that represents the event and the values
752:             *                 of its member fields.
753:             * @see       java.awt.Event#paramString
754:             * @since     JDK1.1
755:             */
756:            public String toString() {
757:                return getClass().getName() + "[" + paramString() + "]";
758:            }
759:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.