Source Code Cross Referenced for ComponentEvent.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.Component;
030        import java.awt.Rectangle;
031
032        /**
033         * A low-level event which indicates that a component moved, changed
034         * size, or changed visibility (also, the root class for the other 
035         * component-level events).
036         * <P>
037         * Component events are provided for notification purposes ONLY;
038         * The AWT will automatically handle component moves and resizes
039         * internally so that GUI layout works properly regardless of
040         * whether a program is receiving these events or not.
041         * <P>
042         * In addition to serving as the base class for other component-related
043         * events (InputEvent, FocusEvent, WindowEvent, ContainerEvent),
044         * this class defines the events that indicate changes in
045         * a component's size, position, or visibility. 
046         * <P>
047         * This low-level event is generated by a component object (such as a 
048         * List) when the component is moved, resized, rendered invisible, or made
049         * visible again. The event is passed to every <code>ComponentListener</code>
050         * or <code>ComponentAdapter</code> object which registered to receive such
051         * events using the component's <code>addComponentListener</code> method.
052         * (<code>ComponentAdapter</code> objects implement the 
053         * <code>ComponentListener</code> interface.) Each such listener object 
054         * gets this <code>ComponentEvent</code> when the event occurs.
055         *
056         * @see ComponentAdapter
057         * @see ComponentListener
058         * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/componentlistener.html">Tutorial: Writing a Component Listener</a>
059         *
060         * @author Carl Quinn
061         * @version 1.37 06/05/07
062         * @since 1.1
063         */
064        public class ComponentEvent extends AWTEvent {
065
066            /**
067             * The first number in the range of ids used for component events.
068             */
069            public static final int COMPONENT_FIRST = 100;
070
071            /**
072             * The last number in the range of ids used for component events.
073             */
074            public static final int COMPONENT_LAST = 103;
075
076            /**
077             * This event indicates that the component's position changed.
078             */
079            public static final int COMPONENT_MOVED = COMPONENT_FIRST;
080
081            /**
082             * This event indicates that the component's size changed.
083             */
084            public static final int COMPONENT_RESIZED = 1 + COMPONENT_FIRST;
085
086            /**
087             * This event indicates that the component was made visible.
088             */
089            public static final int COMPONENT_SHOWN = 2 + COMPONENT_FIRST;
090
091            /**
092             * This event indicates that the component was rendered invisible.
093             */
094            public static final int COMPONENT_HIDDEN = 3 + COMPONENT_FIRST;
095
096            /*
097             * JDK 1.1 serialVersionUID 
098             */
099            private static final long serialVersionUID = 8101406823902992965L;
100
101            /**
102             * Constructs a <code>ComponentEvent</code> object.
103             * <p>Note that passing in an invalid <code>id</code> results in
104             * unspecified behavior. This method throws an
105             * <code>IllegalArgumentException</code> if <code>source</code>
106             * is <code>null</code>.
107             *
108             * @param source the <code>Component</code> that originated the event
109             * @param id     an integer indicating the type of event
110             * @throws IllegalArgumentException if <code>source</code> is null
111             */
112            public ComponentEvent(Component source, int id) {
113                super (source, id);
114            }
115
116            /**
117             * Returns the originator of the event.
118             *
119             * @return the <code>Component</code> object that originated 
120             * the event, or <code>null</code> if the object is not a 
121             * <code>Component</code>.  
122             */
123            public Component getComponent() {
124                return (source instanceof  Component) ? (Component) source
125                        : null;
126            }
127
128            /**
129             * Returns a parameter string identifying this event.
130             * This method is useful for event-logging and for debugging.
131             *
132             * @return a string identifying the event and its attributes
133             */
134            public String paramString() {
135                String typeStr;
136                Rectangle b = (source != null ? ((Component) source)
137                        .getBounds() : null);
138
139                switch (id) {
140                case COMPONENT_SHOWN:
141                    typeStr = "COMPONENT_SHOWN";
142                    break;
143                case COMPONENT_HIDDEN:
144                    typeStr = "COMPONENT_HIDDEN";
145                    break;
146                case COMPONENT_MOVED:
147                    typeStr = "COMPONENT_MOVED (" + b.x + "," + b.y + " "
148                            + b.width + "x" + b.height + ")";
149                    break;
150                case COMPONENT_RESIZED:
151                    typeStr = "COMPONENT_RESIZED (" + b.x + "," + b.y + " "
152                            + b.width + "x" + b.height + ")";
153                    break;
154                default:
155                    typeStr = "unknown type";
156                }
157                return typeStr;
158            }
159        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.