Source Code Cross Referenced for Event.java in  » 6.0-JDK-Core » AWT » 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
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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