Source Code Cross Referenced for MPopupMenuPeer.java in  » 6.0-JDK-Platform » solaris » sun » awt » motif » 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 Platform » solaris » sun.awt.motif 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1996-1998 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:        package sun.awt.motif;
026:
027:        import java.awt.*;
028:        import java.awt.peer.*;
029:
030:        public class MPopupMenuPeer extends MMenuPeer implements  PopupMenuPeer {
031:
032:            static {
033:                initIDs();
034:            }
035:
036:            /* initialize the methodIDs of methods that may be accessed from C */
037:            private native static void initIDs();
038:
039:            native void createMenu(MComponentPeer parent);
040:
041:            void createPopupMenu() {
042:                if (MMenuItemPeer.getParent_NoClientCode(target) instanceof  Component) {
043:                    Component parent = (Component) getParent_NoClientCode(target);
044:                    MComponentPeer parentPeer = (MComponentPeer) MToolkit
045:                            .targetToPeer(parent);
046:                    if (parentPeer == null) {
047:                        // because the menu isn't a component (sigh) we first have to wait
048:                        // for a failure to map the peer which should only happen for a
049:                        // lightweight container, then find the actual native parent from
050:                        // that component.
051:                        parent = MToolkit.getNativeContainer(parent);
052:                        parentPeer = (MComponentPeer) MToolkit
053:                                .targetToPeer(parent);
054:                    }
055:                    createMenu(parentPeer);
056:                    nativeCreated = true;
057:                    createItems((Menu) target);
058:
059:                } else {
060:                    throw new IllegalArgumentException(
061:                            "illegal popup menu container class");
062:                }
063:            }
064:
065:            void createItems(Menu target) {
066:                int nitems = target.getItemCount();
067:                MMenuPeer parent = (MMenuPeer) MToolkit.targetToPeer(target);
068:                for (int i = 0; i < nitems; i++) {
069:                    MenuItem mitem = target.getItem(i);
070:                    MMenuItemPeer mipeer = (MMenuItemPeer) MToolkit
071:                            .targetToPeer(mitem);
072:                    mipeer.create(parent);
073:                    if (mitem instanceof  Menu) {
074:                        createItems((Menu) mitem);
075:                    }
076:                }
077:            }
078:
079:            public MPopupMenuPeer(PopupMenu target) {
080:                // Do NOT instantiate native widget until just before showing the
081:                // menu, else right mouse click will cause display to lock up
082:                // (because of passive grab in Motif)
083:                //
084:                this .target = target;
085:            }
086:
087:            native void pShow(Event evt, int x, int y, MComponentPeer origin);
088:
089:            public void show(Event evt) {
090:
091:                if (!nativeCreated)
092:                    createPopupMenu();
093:
094:                Component origin = (Component) evt.target;
095:                MComponentPeer peer = (MComponentPeer) MToolkit
096:                        .targetToPeer(origin);
097:                int x = evt.x;
098:                int y = evt.y;
099:                if (peer == null) {
100:                    // A failure to map the peer should only happen for a
101:                    // lightweight component, then find the actual native parent from
102:                    // that component.  The event coorinates are going to have to be
103:                    Component nativeOrigin = MToolkit
104:                            .getNativeContainer(origin);
105:                    peer = (MComponentPeer) MToolkit.targetToPeer(nativeOrigin);
106:
107:                    // remove the event coordinates
108:                    for (Component c = origin; c != nativeOrigin; c = MComponentPeer
109:                            .getParent_NoClientCode(c)) {
110:                        Point p = c.getLocation();
111:                        x += p.x;
112:                        y += p.y;
113:                    }
114:                }
115:                pShow(evt, x, y, peer);
116:            }
117:
118:            /**
119:             * This is the callback function called on the Motif thread by
120:             * Popup_popdownCB(Widget, XtPointer, XtPointer) in awt_PopupMenu.c.
121:             */
122:            // NOTE: This method may be called by privileged threads.
123:            //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
124:            private void destroyNativeWidgetAfterGettingTreeLock() {
125:
126:                MToolkit.executeOnEventHandlerThread(target, new Runnable() {
127:                    public void run() {
128:
129:                        Object treeLock = new Button().getTreeLock();
130:                        synchronized (treeLock) {
131:                            destroyNativeWidget();
132:                        }
133:                    }
134:                });
135:            }
136:
137:            native void pDispose();
138:        } // class MPopupMenuPeer
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.