KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > swing > tabcontrol > event > TabActionEvent


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * TabActionEvent.java
21  *
22  * Created on March 17, 2004, 3:48 PM
23  */

24
25 package org.netbeans.swing.tabcontrol.event;
26
27 import java.awt.event.ActionEvent JavaDoc;
28 import java.awt.event.MouseEvent JavaDoc;
29
30 /**
31  * An action event which may be consumed by a listener. These are fired by
32  * TabControl and TabbedContainer to determine if outside code wants to handle
33  * an event, such as clicking the close button (which might be vetoed), or if
34  * the control should handle it itself.
35  *
36  * @author Tim Boudreau
37  */

38 public final class TabActionEvent extends ActionEvent JavaDoc {
39     private MouseEvent JavaDoc mouseEvent = null;
40     private int tabIndex;
41
42     /**
43      * Creates a new instance of TabActionEvent
44      */

45     public TabActionEvent(Object JavaDoc source, String JavaDoc command, int tabIndex) {
46         super(source, ActionEvent.ACTION_PERFORMED, command);
47         this.tabIndex = tabIndex;
48         consumed = false;
49     }
50
51     public TabActionEvent(Object JavaDoc source, String JavaDoc command, int tabIndex,
52                           MouseEvent JavaDoc mouseEvent) {
53         this(source, command, tabIndex);
54         this.mouseEvent = mouseEvent;
55         consumed = false;
56     }
57
58     /**
59      * Consume this event - any changes that should be performed as a result
60      * will be done by external code by manipulating the models or other means
61      */

62     public void consume() {
63         consumed = true;
64     }
65
66     /**
67      * Determine if the event has been consumed
68      */

69     public boolean isConsumed() {
70         return super.isConsumed();
71     }
72
73     /**
74      * If the action event was triggered by a mouse event, get the mouse event
75      * in question
76      *
77      * @return The mouse event, or null
78      */

79     public MouseEvent JavaDoc getMouseEvent() {
80         return mouseEvent;
81     }
82
83     public int getTabIndex() {
84         return tabIndex;
85     }
86
87     public void setSource(Object JavaDoc source) {
88         //Skip some native peer silliness in AWTEvent
89
this.source = source;
90     }
91
92     public String JavaDoc toString() {
93         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("TabActionEvent:"); //NOI18N
94
sb.append ("Tab " + tabIndex + " " + getActionCommand()); //NOI18N
95
return sb.toString();
96     }
97
98 }
99
Popular Tags