Source Code Cross Referenced for ItemEvent.java in  » 6.0-JDK-Core » AWT » java » awt » event » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1996-2007 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
026        package java.awt.event;
027
028        import java.awt.AWTEvent;
029        import java.awt.ItemSelectable;
030
031        /**
032         * A semantic event which indicates that an item was selected or deselected.
033         * This high-level event is generated by an ItemSelectable object (such as a 
034         * List) when an item is selected or deselected by the user.
035         * The event is passed to every <code>ItemListener</code> object which
036         * registered to receive such events using the component's
037         * <code>addItemListener</code> method. 
038         * <P>
039         * The object that implements the <code>ItemListener</code> interface gets
040         * this <code>ItemEvent</code> when the event occurs. The listener is
041         * spared the details of processing individual mouse movements and mouse
042         * clicks, and can instead process a "meaningful" (semantic) event like
043         * "item selected" or "item deselected". 
044         *
045         * @version 1.38 06/05/07
046         * @author Carl Quinn
047         *
048         * @see java.awt.ItemSelectable
049         * @see ItemListener
050         * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/itemlistener.html">Tutorial: Writing an Item Listener</a>
051         *
052         * @since 1.1
053         */
054        public class ItemEvent extends AWTEvent {
055
056            /**
057             * The first number in the range of ids used for item events.
058             */
059            public static final int ITEM_FIRST = 701;
060
061            /**
062             * The last number in the range of ids used for item events.
063             */
064            public static final int ITEM_LAST = 701;
065
066            /** 
067             * This event id indicates that an item's state changed.
068             */
069            public static final int ITEM_STATE_CHANGED = ITEM_FIRST; //Event.LIST_SELECT 
070
071            /**
072             * This state-change value indicates that an item was selected.
073             */
074            public static final int SELECTED = 1;
075
076            /** 
077             * This state-change-value indicates that a selected item was deselected.
078             */
079            public static final int DESELECTED = 2;
080
081            /**
082             * The item whose selection state has changed.
083             *
084             * @serial
085             * @see #getItem()
086             */
087            Object item;
088
089            /**
090             * <code>stateChange</code> indicates whether the <code>item</code>
091             * was selected or deselected.
092             *
093             * @serial
094             * @see #getStateChange()
095             */
096            int stateChange;
097
098            /*
099             * JDK 1.1 serialVersionUID 
100             */
101            private static final long serialVersionUID = -608708132447206933L;
102
103            /**
104             * Constructs an <code>ItemEvent</code> object.
105             * <p>Note that passing in an invalid <code>id</code> results in
106             * unspecified behavior. This method throws an
107             * <code>IllegalArgumentException</code> if <code>source</code>
108             * is <code>null</code>.
109             *
110             * @param source the <code>ItemSelectable</code> object
111             *               that originated the event
112             * @param id     an integer that identifies the event type
113             * @param item   an object -- the item affected by the event
114             * @param stateChange 
115             *               an integer that indicates whether the item was
116             *               selected or deselected
117             * @throws IllegalArgumentException if <code>source</code> is null
118             */
119            public ItemEvent(ItemSelectable source, int id, Object item,
120                    int stateChange) {
121                super (source, id);
122                this .item = item;
123                this .stateChange = stateChange;
124            }
125
126            /**
127             * Returns the originator of the event.
128             *
129             * @return the ItemSelectable object that originated the event.
130             */
131            public ItemSelectable getItemSelectable() {
132                return (ItemSelectable) source;
133            }
134
135            /**
136             * Returns the item affected by the event.
137             *
138             * @return the item (object) that was affected by the event
139             */
140            public Object getItem() {
141                return item;
142            }
143
144            /**
145             * Returns the type of state change (selected or deselected).
146             *
147             * @return an integer that indicates whether the item was selected
148             *         or deselected
149             *
150             * @see #SELECTED
151             * @see #DESELECTED
152             */
153            public int getStateChange() {
154                return stateChange;
155            }
156
157            /**
158             * Returns a parameter string identifying this item event.
159             * This method is useful for event-logging and for debugging.
160             *
161             * @return a string identifying the event and its attributes
162             */
163            public String paramString() {
164                String typeStr;
165                switch (id) {
166                case ITEM_STATE_CHANGED:
167                    typeStr = "ITEM_STATE_CHANGED";
168                    break;
169                default:
170                    typeStr = "unknown type";
171                }
172
173                String stateStr;
174                switch (stateChange) {
175                case SELECTED:
176                    stateStr = "SELECTED";
177                    break;
178                case DESELECTED:
179                    stateStr = "DESELECTED";
180                    break;
181                default:
182                    stateStr = "unknown type";
183                }
184                return typeStr + ",item=" + item + ",stateChange=" + stateStr;
185            }
186
187        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.