Source Code Cross Referenced for SMenuBar.java in  » Swing-Library » wings3 » org » wings » 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 » Swing Library » wings3 » org.wings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2000,2005 wingS development team.
003:         *
004:         * This file is part of wingS (http://wingsframework.org).
005:         *
006:         * wingS is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU Lesser General Public License
008:         * as published by the Free Software Foundation; either version 2.1
009:         * of the License, or (at your option) any later version.
010:         *
011:         * Please see COPYING for the complete licence.
012:         */
013:        package org.wings;
014:
015:        import org.wings.plaf.MenuBarCG;
016:
017:        import javax.swing.*;
018:        import java.awt.*;
019:        import java.util.ArrayList;
020:
021:        /**
022:         * Contains SMenu objects to construct a menu.
023:         * <p/>
024:         * When the user selects a SMenu object, its
025:         * associated {@link org.wings.SMenu} is displayed, allowing the
026:         * user to select one of the {@link org.wings.SMenuItem}s on it.
027:         * <p/>
028:         * Component are rendered in the order of the container. If a component is right
029:         * aligned, every following components are also right aligned. So you have to
030:         * sort the components in the order you want and have to take care that te
031:         * components are sorted by their horizontal alignment
032:         *
033:         * @author <a href="mailto:andre@lison.de">Andre Lison</a>
034:         * @author <a href="mailto:armin.haaf@mercatis.de">Armin Haaf</a>
035:         * @see SMenu
036:         */
037:        public class SMenuBar extends SContainer {
038:            /*
039:             * Model for the selected subcontrol
040:             */
041:            private transient SingleSelectionModel selectionModel;
042:
043:            private boolean paintBorder = true;
044:            private Insets margin = null;
045:
046:            /**
047:             * Creates a new menu bar.
048:             */
049:            public SMenuBar() {
050:                super ();
051:                setSelectionModel(new DefaultSingleSelectionModel());
052:            }
053:
054:            /**
055:             * Returns the model object that handles single selections.
056:             *
057:             * @return the SingleSelectionModel in use
058:             * @see SingleSelectionModel
059:             */
060:            public SingleSelectionModel getSelectionModel() {
061:                return selectionModel;
062:            }
063:
064:            /**
065:             * Set the model object to handle single selections.
066:             *
067:             * @param model the SingleSelectionModel to use
068:             * description: The selection model, recording which child is selected.
069:             * @see SingleSelectionModel
070:             */
071:            public void setSelectionModel(SingleSelectionModel model) {
072:                this .selectionModel = model;
073:            }
074:
075:            /**
076:             * Appends the specified menu to the end of the menu bar.
077:             *
078:             * @param menu the SMenu component to add
079:             */
080:            public SMenuItem add(SMenu menu) {
081:                getSession().getMenuManager().registerMenuLink(menu, this );
082:                super .add(menu);
083:                return menu;
084:            }
085:
086:            /**
087:             * Removes the specified menu from the menu bar.
088:             *
089:             * @param menu the SMenu component to remove
090:             */
091:            public void remove(SMenu menu) {
092:                getSession().getMenuManager().deregisterMenuLink(menu, this );
093:                super .remove(menu);
094:            }
095:
096:            /**
097:             * Gets the menu at the specified position in the menu bar.
098:             *
099:             * @param index an int giving the position in the menu bar, where
100:             *              0 is the first position
101:             * @return the SMenu at that position
102:             */
103:            public SMenu getMenu(int index) {
104:                SComponent c = super .getComponent(index);
105:                if (c instanceof  SMenu)
106:                    return (SMenu) c;
107:                return null;
108:            }
109:
110:            /**
111:             * Returns the number of items in the menu bar.
112:             *
113:             * @return the number of items in the menu bar
114:             */
115:            public int getMenuCount() {
116:                return getComponentCount();
117:            }
118:
119:            /**
120:             * Returns the index of the specified component.
121:             *
122:             * @param c the <code>SComponent</code> to find
123:             * @return an integer giving the component's position, where 0 is first;
124:             *         or -1 if it can't be found
125:             */
126:            public int getComponentIndex(SComponent c) {
127:                int ncomponents = this .getComponentCount();
128:                for (int i = 0; i < ncomponents; i++) {
129:                    SComponent comp = getComponent(i);
130:                    if (comp == c)
131:                        return i;
132:                }
133:                return -1;
134:            }
135:
136:            /**
137:             * Sets the currently selected component, producing a
138:             * a change to the selection model.
139:             *
140:             * @param sel the SComponent to select
141:             */
142:            public void setSelected(SComponent sel) {
143:                SingleSelectionModel model = getSelectionModel();
144:                int index = getComponentIndex(sel);
145:                model.setSelectedIndex(index);
146:            }
147:
148:            /**
149:             * Returns true if the MenuBar currently has a component selected
150:             *
151:             * @return true if a selection has been made, else false
152:             */
153:            public boolean isSelected() {
154:                return selectionModel.isSelected();
155:            }
156:
157:            /**
158:             * Returns true if the Menubar's border should be painted.
159:             *
160:             * @return true if the border should be painted, else false
161:             */
162:            public boolean isBorderPainted() {
163:                return paintBorder;
164:            }
165:
166:            /**
167:             * Sets whether the border should be painted.
168:             *
169:             * @param b if true and border property is not null, the border is painted.
170:             * attribute: visualUpdate true
171:             * description: Whether the border should be painted.
172:             * @see #isBorderPainted
173:             */
174:            public void setBorderPainted(boolean b) {
175:                paintBorder = b;
176:            }
177:
178:            /**
179:             * Sets the margin between the menubar's border and
180:             * its menus. Setting to null will cause the menubar to
181:             * use the default margins.
182:             *
183:             * @param m an Insets object containing the margin values
184:             * attribute: visualUpdate true
185:             * description: The space between the menubar's border and its contents
186:             * @see Insets
187:             */
188:            public void setMargin(Insets m) {
189:                this .margin = m;
190:            }
191:
192:            /**
193:             * Returns the margin between the menubar's border and
194:             * its menus.
195:             *
196:             * @return an Insets object containing the margin values
197:             * @see Insets
198:             */
199:            public Insets getMargin() {
200:                if (margin == null) {
201:                    return new Insets(0, 0, 0, 0);
202:                } else {
203:                    return margin;
204:                }
205:            }
206:
207:            /**
208:             * Returns a string representation of this SMenuBar. This method
209:             * is intended to be used only for debugging purposes, and the
210:             * content and format of the returned string may vary between
211:             * implementations. The returned string may be empty but may not
212:             * be <code>null</code>.
213:             *
214:             * @return a string representation of this SMenuBar.
215:             */
216:            protected String paramString() {
217:                String paintBorderString = (paintBorder ? "true" : "false");
218:                String marginString = (margin != null ? margin.toString() : "");
219:
220:                return super .paramString() + ",margin=" + marginString
221:                        + ",paintBorder=" + paintBorderString;
222:            }
223:
224:            /* doc see SComponent */
225:            public void setCG(MenuBarCG cg) {
226:                super .setCG(cg);
227:            }
228:
229:            /* doc see SComponent */
230:            public ArrayList getMenus() {
231:                ArrayList menus = new ArrayList();
232:                if (isVisible()) {
233:                    SPopupMenu pmenu = getComponentPopupMenu();
234:                    if (pmenu != null) {
235:                        menus.add(pmenu);
236:                    }
237:                    for (int i = 0; i < getComponentCount(); i++) {
238:                        SMenu menu = (SMenu) getComponent(i);
239:                        if (menus.contains(menu)) {
240:                            remove(menu);
241:                        }
242:                        menus.add(menu);
243:                    }
244:                }
245:                return menus;
246:            }
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.