Source Code Cross Referenced for AbstractCellEditor.java in  » 6.0-JDK-Core » swing » javax » swing » 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 » swing » javax.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1999-2006 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 javax.swing;
027
028        import javax.swing.event.*;
029        import java.util.EventObject;
030        import java.io.Serializable;
031
032        /**
033         * @version 1.19 05/05/07 
034         * 
035         * A base class for <code>CellEditors</code>, providing default
036         * implementations for the methods in the <code>CellEditor</code>
037         * interface except <code>getCellEditorValue()</code>. 
038         * Like the other abstract implementations in Swing, also manages a list 
039         * of listeners. 
040         *
041         * <p>
042         * <strong>Warning:</strong>
043         * Serialized objects of this class will not be compatible with
044         * future Swing releases. The current serialization support is
045         * appropriate for short term storage or RMI between applications running
046         * the same version of Swing.  As of 1.4, support for long term storage
047         * of all JavaBeans<sup><font size="-2">TM</font></sup>
048         * has been added to the <code>java.beans</code> package.
049         * Please see {@link java.beans.XMLEncoder}.
050         * 
051         * @author Philip Milne
052         * @since 1.3
053         */
054
055        public abstract class AbstractCellEditor implements  CellEditor,
056                Serializable {
057
058            protected EventListenerList listenerList = new EventListenerList();
059            transient protected ChangeEvent changeEvent = null;
060
061            // Force this to be implemented. 
062            // public Object  getCellEditorValue()  
063
064            /**
065             * Returns true.
066             * @param e  an event object
067             * @return true
068             */
069            public boolean isCellEditable(EventObject e) {
070                return true;
071            }
072
073            /**
074             * Returns true.
075             * @param anEvent  an event object
076             * @return true
077             */
078            public boolean shouldSelectCell(EventObject anEvent) {
079                return true;
080            }
081
082            /**
083             * Calls <code>fireEditingStopped</code> and returns true.
084             * @return true
085             */
086            public boolean stopCellEditing() {
087                fireEditingStopped();
088                return true;
089            }
090
091            /**
092             * Calls <code>fireEditingCanceled</code>.
093             */
094            public void cancelCellEditing() {
095                fireEditingCanceled();
096            }
097
098            /**
099             * Adds a <code>CellEditorListener</code> to the listener list.
100             * @param l  the new listener to be added
101             */
102            public void addCellEditorListener(CellEditorListener l) {
103                listenerList.add(CellEditorListener.class, l);
104            }
105
106            /**
107             * Removes a <code>CellEditorListener</code> from the listener list.
108             * @param l  the listener to be removed
109             */
110            public void removeCellEditorListener(CellEditorListener l) {
111                listenerList.remove(CellEditorListener.class, l);
112            }
113
114            /**
115             * Returns an array of all the <code>CellEditorListener</code>s added
116             * to this AbstractCellEditor with addCellEditorListener().
117             *
118             * @return all of the <code>CellEditorListener</code>s added or an empty
119             *         array if no listeners have been added
120             * @since 1.4
121             */
122            public CellEditorListener[] getCellEditorListeners() {
123                return (CellEditorListener[]) listenerList
124                        .getListeners(CellEditorListener.class);
125            }
126
127            /**
128             * Notifies all listeners that have registered interest for
129             * notification on this event type.  The event instance 
130             * is created lazily.
131             *
132             * @see EventListenerList
133             */
134            protected void fireEditingStopped() {
135                // Guaranteed to return a non-null array
136                Object[] listeners = listenerList.getListenerList();
137                // Process the listeners last to first, notifying
138                // those that are interested in this event
139                for (int i = listeners.length - 2; i >= 0; i -= 2) {
140                    if (listeners[i] == CellEditorListener.class) {
141                        // Lazily create the event:
142                        if (changeEvent == null)
143                            changeEvent = new ChangeEvent(this );
144                        ((CellEditorListener) listeners[i + 1])
145                                .editingStopped(changeEvent);
146                    }
147                }
148            }
149
150            /**
151             * Notifies all listeners that have registered interest for
152             * notification on this event type.  The event instance 
153             * is created lazily.
154             *
155             * @see EventListenerList
156             */
157            protected void fireEditingCanceled() {
158                // Guaranteed to return a non-null array
159                Object[] listeners = listenerList.getListenerList();
160                // Process the listeners last to first, notifying
161                // those that are interested in this event
162                for (int i = listeners.length - 2; i >= 0; i -= 2) {
163                    if (listeners[i] == CellEditorListener.class) {
164                        // Lazily create the event:
165                        if (changeEvent == null)
166                            changeEvent = new ChangeEvent(this );
167                        ((CellEditorListener) listeners[i + 1])
168                                .editingCanceled(changeEvent);
169                    }
170                }
171            }
172        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.