Source Code Cross Referenced for WindowXWindow.java in  » 6.0-JDK-Modules » j2me » java » awt » 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 » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)WindowXWindow.java	1.21 06/10/10
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:
028:        package java.awt;
029:
030:        import java.awt.event.*;
031:
032:        /** The base class for all top level windows. Top level X windows
033:         have the X root window as their parent.
034:         @version 1.17, 08/19/02
035:         @author Nicholas Allen*/
036:
037:        class WindowXWindow extends HeavyweightComponentXWindow {
038:            public WindowXWindow(Window window) {
039:                super (window);
040:                topBorder = defaultTopBorder;
041:                leftBorder = defaultLeftBorder;
042:                bottomBorder = defaultBottomBorder;
043:                rightBorder = defaultRightBorder;
044:            }
045:
046:            void create() {
047:                this .windowID = create((component.parent != null && component.parent.xwindow != null) ? component.parent.xwindow.windowID
048:                        : 0);
049:            }
050:
051:            native int create(int owner);
052:
053:            final native void setTitle(String title);
054:
055:            final void setIconImage(Image image) {
056:                if (image != null)
057:                    setIconImageNative(((X11Image) image).Xpixmap);
058:            }
059:
060:            final native void setIconImageNative(int pixmap);
061:
062:            final native void toFront();
063:
064:            final native void toBack();
065:
066:            final synchronized void setResizable(boolean b) {
067:                resizable = b;
068:                if (!resizable) {
069:                    int width = Math.max(1, component.width - leftBorder
070:                            - rightBorder);
071:                    int height = Math.max(1, component.height - topBorder
072:                            - bottomBorder);
073:                    setSizeHintsNative(width, height, width, height);
074:                } else
075:                    setSizeHints(component.getMinimumSize(), component
076:                            .getMaximumSize());
077:            }
078:
079:            /** Sets the event mask for the X window using the supplied event mask (see AWTEvent).
080:             This lets the X server know what kinds of events we are interested in. */
081:
082:            final native void setMouseEventMask(long mask);
083:
084:            final synchronized void setBounds(int x, int y, int width,
085:                    int height) {
086:                width = Math.max(1, width - leftBorder - rightBorder);
087:                height = Math.max(1, height - topBorder - bottomBorder);
088:                if (!resizable)
089:                    setSizeHintsNative(width, height, width, height);
090:                setBoundsNative(x, y, width, height);
091:            }
092:
093:            native void setBoundsNative(int x, int y, int width, int height);
094:
095:            /** Sets the hints for the window manager for the minimum/maximum size of the window.
096:             The window manager may or may not respect this. */
097:
098:            final synchronized void setSizeHints(Dimension minSize,
099:                    Dimension maxSize) {
100:                if (resizable) {
101:                    minSize.width = Math.max(minSize.width - leftBorder
102:                            - rightBorder, 1);
103:                    minSize.height = Math.max(minSize.height - topBorder
104:                            - bottomBorder, 1);
105:                    maxSize.width = Math.max(Math.min(maxSize.width
106:                            - leftBorder - rightBorder, Short.MAX_VALUE),
107:                            minSize.width);
108:                    maxSize.height = Math.max(Math.min(maxSize.height
109:                            - topBorder - bottomBorder, Short.MAX_VALUE),
110:                            minSize.height);
111:                    setSizeHintsNative(minSize.width, minSize.height,
112:                            maxSize.width, maxSize.height);
113:                }
114:            }
115:
116:            private final native void setSizeHintsNative(int minWidth,
117:                    int minHeight, int maxWidth, int maxHeight);
118:
119:            void map() {
120:                mapNative();
121:            }
122:
123:            /** Called by the native code when an area of the X Window is exposed.
124:             This posts a paint event into Java's event queue for processing by Java
125:             so that the exposed area is redrawn. */
126:
127:            final void postPaintEvent(int x, int y, int width, int height) {
128:                // Translate paint position to take into acount borders of window.
129:                // Java expects window coordinates to be relative to the window manager's
130:                // window.
131:
132:                super .postPaintEvent(x + leftBorder, y + topBorder, width,
133:                        height);
134:            }
135:
136:            /** Called when a mouse event is received from the X server for this X window. We post a
137:             mouse event into Java's event queue for processing. This is overriden to translate the coordinates
138:             to the outer window's coordinate system. */
139:
140:            void postMouseButtonEvent(int id, long when, int modifiers, int x,
141:                    int y) {
142:                super .postMouseButtonEvent(id, when, modifiers, x + leftBorder,
143:                        y + topBorder);
144:            }
145:
146:            void postMouseEvent(int id, long when, int modifiers, int x, int y) {
147:                super .postMouseEvent(id, when, modifiers, x + leftBorder, y
148:                        + topBorder);
149:            }
150:
151:            private void postWindowEvent(int id) {
152:                Toolkit.getEventQueue().postEvent(
153:                        new WindowEvent((Window) component, id));
154:            }
155:
156:            private void postKeyEvent(int id, long when, int modifiers,
157:                    int keyCode, char keyChar) {
158:                Toolkit.getEventQueue().postEvent(
159:                        new KeyEvent(component, id, when, modifiers, keyCode,
160:                                keyChar));
161:            }
162:
163:            /* Sets the borders of this window. This is called if the window is reparented. We store the values
164:             so we can translate paint events and component positions as Java expects coordinates relative
165:             to the window manager's window and not our own. These values are also used for the insets of the
166:             window. */
167:
168:            private synchronized void setBorders(int top, int left, int bottom,
169:                    int right) {
170:                if (top != topBorder || left != leftBorder
171:                        || bottom != bottomBorder || right != rightBorder) {
172:                    topBorder = top;
173:                    leftBorder = left;
174:                    bottomBorder = bottom;
175:                    rightBorder = right;
176:                    // Insets will have changed so have to revalidate window
177:
178:                    EventQueue.invokeLater(new Runnable() {
179:                        public void run() {
180:                            component.invalidate();
181:                            component.validate();
182:                            component.repaint();
183:                        }
184:                    });
185:                }
186:                setDefaultBorders(top, left, bottom, right);
187:            }
188:
189:            void setDefaultBorders(int top, int left, int bottom, int right) {
190:                defaultTopBorder = top;
191:                defaultBottomBorder = bottom;
192:                defaultLeftBorder = left;
193:                defaultRightBorder = right;
194:            }
195:
196:            void postMovedEvent() {
197:                Toolkit.getEventQueue().postEvent(
198:                        new ComponentEvent(component,
199:                                ComponentEvent.COMPONENT_MOVED));
200:            }
201:
202:            void postResizedEvent() {
203:                Toolkit.getEventQueue().postEvent(
204:                        new ComponentEvent(component,
205:                                ComponentEvent.COMPONENT_RESIZED));
206:            }
207:
208:            private int outerWindow;
209:            int topBorder, leftBorder, bottomBorder, rightBorder;
210:            private boolean resizable = true;
211:            private static int defaultTopBorder = 0;
212:            private static int defaultLeftBorder = 0;
213:            private static int defaultBottomBorder = 0;
214:            private static int defaultRightBorder = 0;
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.