Source Code Cross Referenced for JMenuBar.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » 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 » Apache Harmony Java SE » javax package » javax.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package javax.swing;
019:
020:        import java.awt.Component;
021:        import java.awt.Graphics;
022:        import java.awt.Insets;
023:        import java.awt.event.KeyEvent;
024:        import java.awt.event.MouseEvent;
025:        import javax.accessibility.Accessible;
026:        import javax.accessibility.AccessibleContext;
027:        import javax.accessibility.AccessibleRole;
028:        import javax.accessibility.AccessibleSelection;
029:        import javax.accessibility.AccessibleStateSet;
030:        import javax.swing.plaf.MenuBarUI;
031:        import org.apache.harmony.luni.util.NotImplementedException;
032:        import org.apache.harmony.x.swing.StringConstants;
033:        import org.apache.harmony.x.swing.Utilities;
034:
035:        import org.apache.harmony.x.swing.internal.nls.Messages;
036:
037:        /**
038:         * <p>
039:         * <i>JMenuBar</i>
040:         * </p>
041:         * <h3>Implementation Notes:</h3>
042:         * <ul>
043:         * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
044:         * optimization, not as a guarantee of serialization compatibility.</li>
045:         * </ul>
046:         */
047:        public class JMenuBar extends JComponent implements  Accessible,
048:                MenuElement {
049:            private static final long serialVersionUID = 6620404810314292434L;
050:
051:            // TODO: implement
052:            protected class AccessibleJMenuBar extends AccessibleJComponent
053:                    implements  AccessibleSelection {
054:                private static final long serialVersionUID = 1L;
055:
056:                public void addAccessibleSelection(int i)
057:                        throws NotImplementedException {
058:                    throw new NotImplementedException();
059:                }
060:
061:                public void clearAccessibleSelection()
062:                        throws NotImplementedException {
063:                    throw new NotImplementedException();
064:                }
065:
066:                public Accessible getAccessibleSelection(int i)
067:                        throws NotImplementedException {
068:                    throw new NotImplementedException();
069:                }
070:
071:                public int getAccessibleSelectionCount()
072:                        throws NotImplementedException {
073:                    throw new NotImplementedException();
074:                }
075:
076:                @Override
077:                public AccessibleRole getAccessibleRole() {
078:                    return AccessibleRole.MENU_BAR;
079:                }
080:
081:                @Override
082:                public AccessibleSelection getAccessibleSelection()
083:                        throws NotImplementedException {
084:                    throw new NotImplementedException();
085:                }
086:
087:                @Override
088:                public AccessibleStateSet getAccessibleStateSet()
089:                        throws NotImplementedException {
090:                    throw new NotImplementedException();
091:                }
092:
093:                public boolean isAccessibleChildSelected(int i)
094:                        throws NotImplementedException {
095:                    throw new NotImplementedException();
096:                }
097:
098:                public void removeAccessibleSelection(int i)
099:                        throws NotImplementedException {
100:                    throw new NotImplementedException();
101:                }
102:
103:                public void selectAllAccessibleSelection()
104:                        throws NotImplementedException {
105:                    throw new NotImplementedException();
106:                }
107:            }
108:
109:            private final static String UI_CLASS_ID = "MenuBarUI";
110:
111:            private SingleSelectionModel selectionModel = new DefaultSingleSelectionModel();
112:
113:            private boolean borderPainted = true;
114:
115:            private Insets margin;
116:
117:            public JMenuBar() {
118:                updateUI();
119:            }
120:
121:            public JMenu add(JMenu menu) {
122:                super .add(menu);
123:                return menu;
124:            }
125:
126:            @Override
127:            public AccessibleContext getAccessibleContext() {
128:                return (accessibleContext == null) ? (accessibleContext = new AccessibleJMenuBar())
129:                        : accessibleContext;
130:            }
131:
132:            public JMenu getMenu(int index) {
133:                Component c = getComponent(index);
134:                return (c instanceof  JMenu) ? (JMenu) c : null;
135:            }
136:
137:            public int getMenuCount() {
138:                return getComponentCount();
139:            }
140:
141:            @Deprecated
142:            public Component getComponentAtIndex(int index) {
143:                return getComponent(index);
144:            }
145:
146:            public int getComponentIndex(Component c) {
147:                for (int i = 0; i < getComponentCount(); i++) {
148:                    if (getComponent(i) == c) {
149:                        return i;
150:                    }
151:                }
152:                return -1;
153:            }
154:
155:            public MenuElement[] getSubElements() {
156:                return Utilities.getSubElements(this );
157:            }
158:
159:            public void setSelectionModel(SingleSelectionModel model) {
160:                SingleSelectionModel oldValue = selectionModel;
161:                selectionModel = model;
162:                firePropertyChange(StringConstants.SELECTION_MODEL_PROPERTY,
163:                        oldValue, selectionModel);
164:            }
165:
166:            public SingleSelectionModel getSelectionModel() {
167:                return selectionModel;
168:            }
169:
170:            public void setSelected(Component selection) {
171:                if (selectionModel != null) {
172:                    selectionModel
173:                            .setSelectedIndex(getComponentIndex(selection));
174:                }
175:            }
176:
177:            public boolean isSelected() {
178:                return (selectionModel != null) ? selectionModel.isSelected()
179:                        : false;
180:            }
181:
182:            public void setBorderPainted(boolean painted) {
183:                boolean oldValue = borderPainted;
184:                borderPainted = painted;
185:                firePropertyChange(
186:                        AbstractButton.BORDER_PAINTED_CHANGED_PROPERTY,
187:                        oldValue, borderPainted);
188:            }
189:
190:            public boolean isBorderPainted() {
191:                return borderPainted;
192:            }
193:
194:            @Override
195:            protected void paintBorder(Graphics g) {
196:                if (isBorderPainted()) {
197:                    super .paintBorder(g);
198:                }
199:            }
200:
201:            @Override
202:            protected boolean processKeyBinding(KeyStroke ks, KeyEvent event,
203:                    int condition, boolean pressed) {
204:                MenuSelectionManager.defaultManager().processKeyEvent(event);
205:                if ((event != null) && event.isConsumed()) {
206:                    return true;
207:                }
208:                if (super .processKeyBinding(ks, event, condition, pressed)) {
209:                    return true;
210:                }
211:                return SwingUtilities.processKeyEventOnChildren(this , event);
212:            }
213:
214:            public void processKeyEvent(KeyEvent e, MenuElement[] path,
215:                    MenuSelectionManager manager) {
216:            }
217:
218:            public void processMouseEvent(MouseEvent event, MenuElement[] path,
219:                    MenuSelectionManager manager) {
220:            }
221:
222:            public void menuSelectionChanged(boolean isIncluded) {
223:            }
224:
225:            public Component getComponent() {
226:                return this ;
227:            }
228:
229:            public void setHelpMenu(JMenu menu) {
230:                throw new Error(Messages.getString(
231:                        "swing.err.0C", "setHelpMenu()")); //$NON-NLS-1$ //$NON-NLS-2$
232:            }
233:
234:            public JMenu getHelpMenu() {
235:                throw new Error(Messages.getString(
236:                        "swing.err.0C", "getHelpMenu()")); //$NON-NLS-1$ //$NON-NLS-2$ 
237:            }
238:
239:            public void setMargin(Insets margin) {
240:                Insets oldValue = this .margin;
241:                this .margin = margin;
242:                firePropertyChange(AbstractButton.MARGIN_CHANGED_PROPERTY,
243:                        oldValue, margin);
244:            }
245:
246:            public Insets getMargin() {
247:                return margin;
248:            }
249:
250:            @Override
251:            public String getUIClassID() {
252:                return UI_CLASS_ID;
253:            }
254:
255:            public MenuBarUI getUI() {
256:                return (MenuBarUI) ui;
257:            }
258:
259:            public void setUI(MenuBarUI ui) {
260:                super .setUI(ui);
261:            }
262:
263:            @Override
264:            public void updateUI() {
265:                setUI((MenuBarUI) UIManager.getUI(this));
266:            }
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.