Source Code Cross Referenced for PPCWindowPeer.java in  » 6.0-JDK-Modules » j2me » sun » awt » pocketpc » 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
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » sun.awt.pocketpc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)PPCWindowPeer.java	1.4 02/12/09
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation. 
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt). 
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA 
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions. 
025:         */
026:
027:        package sun.awt.pocketpc;
028:
029:        import java.util.Vector;
030:        import sun.awt.peer.*;
031:        import java.awt.*;
032:        import java.awt.event.*;
033:        import sun.awt.PeerBasedToolkit;
034:
035:        class PPCWindowPeer extends PPCPanelPeer implements  WindowPeer {
036:            private static native void initIDs();
037:
038:            static {
039:                initIDs();
040:            }
041:
042:            // PPCComponentPeer overrides
043:
044:            public void dispose() {
045:                allWindows.removeElement(this );
046:                super .dispose();
047:            }
048:
049:            // WindowPeer implementation
050:
051:            public native void toFront();
052:
053:            public native void toBack();
054:
055:            // FramePeer & DialogPeer partial shared implementation
056:
057:            public void setTitle(String title) {
058:                // allow a null title to pass as an empty string.
059:                if (title == null) {
060:                    title = new String("");
061:                }
062:                _setTitle(title);
063:            }
064:
065:            native void _setTitle(String title);
066:
067:            public void setResizable(boolean resizable) {
068:                _setResizable(resizable);
069:                ((Component) target).invalidate(); // Insets were updated.
070:            }
071:
072:            public native void _setResizable(boolean resizable);
073:
074:            // Toolkit & peer internals
075:
076:            static Vector allWindows = new Vector(); //!CQ for anchoring windows, frames, dialogs
077:
078:            PPCWindowPeer(Window target) {
079:                super (target);
080:            }
081:
082:            void initialize() {
083:                super .initialize();
084:
085:                updateInsets(insets_);
086:                allWindows.addElement(this );
087:
088:                Font f = ((Window) target).getFont();
089:                if (f == null) {
090:                    f = new Font("Dialog", Font.PLAIN, 12);
091:                    ((Window) target).setFont(f);
092:                    setFont(f);
093:                }
094:            }
095:
096:            native void create(PPCComponentPeer parent);
097:
098:            // Synchronize the insets members (here & in helper) with actual window 
099:            // state.
100:            native void updateInsets(Insets i);
101:
102:            // Called from AwtFrame::WmActivate
103:            void postFocusOnActivate() {
104:                PPCToolkit.postEvent(new FocusOnActivate());
105:            }
106:
107:            class FocusOnActivate extends AWTEvent implements  ActiveEvent {
108:                public FocusOnActivate() {
109:                    super ((Component) PPCWindowPeer.this .target, 0);
110:                }
111:
112:                public void dispatch() {
113:                    PPCComponentPeer peer;
114:
115:                    peer = getFocusPeer();
116:                    if (peer == null) {
117:                        // no heavyweight had the focus, so set a default focus
118:                        peer = setDefaultFocus();
119:                    }
120:
121:                    if (peer != null) {
122:                        requestComponentFocusIfActive(peer);
123:                    }
124:                }
125:            }
126:
127:            // Requests the focus be set to a given component iff the containing
128:            // window is activated
129:            native void requestComponentFocusIfActive(PPCComponentPeer peer);
130:
131:            // Get the peer of the heavyweight component with focus
132:            // in this window
133:            PPCComponentPeer getFocusPeer() {
134:                Component c = ((Window) target).getFocusOwner();
135:                while (c != null) {
136:                    ComponentPeer peer = (ComponentPeer) PeerBasedToolkit
137:                            .getComponentPeer(c);
138:                    if (peer != null && peer instanceof  PPCComponentPeer) {
139:                        return (PPCComponentPeer) peer;
140:                    } else {
141:                        // peerless sub-component, try parent.
142:                        c = c.getParent();
143:                    }
144:                }
145:                return null; // no child has focus
146:            }
147:
148:            // This method is called to set focus to a Motif-like "reasonable"
149:            // default.  It's only called if focus was not explicitly set by either the
150:            // Java app or the user.
151:            PPCComponentPeer setDefaultFocus() {
152:                // Find first focus-traversable component.
153:                Component c = setDefaultFocus((Container) target);
154:                if (c == null) {
155:                    // No focus-traversable component found, so set focus the 1st leaf node
156:                    c = (Component) target;
157:                    while (c instanceof  Container
158:                            && ((Container) c).getComponentCount() > 0
159:                            && PeerBasedToolkit.getComponentPeer(c) != null) {
160:                        Component child = getContainerElement((Container) c, 0);
161:                        if (child.isVisible() && child.isEnabled()) {
162:                            c = child;
163:                        } else {
164:                            break; // Bug fix for bug #4038896 (Oracle deadlock bug) - Jonathan Locke
165:                        }
166:                    }
167:                }
168:                ComponentPeer peer = PeerBasedToolkit.getComponentPeer(c);
169:                if (peer instanceof  sun.awt.peer.LightweightPeer)
170:                    return null;
171:                else
172:                    return (PPCComponentPeer) peer;
173:            }
174:
175:            // This is similar to Window.activateFocus(), but won't trip over any locks
176:            // held by client code.
177:            private Component setDefaultFocus(Container cont) {
178:                int ncomponents = cont.getComponentCount();
179:                for (int i = 0; i < ncomponents; i++) {
180:                    Component c = getContainerElement(cont, i);
181:                    if (c.isVisible() && c.isEnabled()
182:                            && c.isFocusTraversable()) {
183:                        return c;
184:                    }
185:                    if (c instanceof  Container && c.isVisible()
186:                            && c.isEnabled()) {
187:                        Component child = setDefaultFocus((Container) c);
188:                        if (child != null) {
189:                            return child;
190:                        }
191:                    }
192:                }
193:                return null;
194:            }
195:
196:            private Component getContainerElement(Container c, int i) {
197:                return c.getComponent(i);
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.