Source Code Cross Referenced for XRollupBar.java in  » XML-UI » xui32 » com » xoetrope » 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 » XML UI » xui32 » com.xoetrope.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.awt;
002:
003:        import java.awt.CardLayout;
004:        import java.awt.Color;
005:        import java.awt.Component;
006:        import java.awt.GridLayout;
007:        import java.awt.event.ActionEvent;
008:        import java.awt.event.ActionListener;
009:        import java.util.Hashtable;
010:        import net.xoetrope.builder.XuiBuilder;
011:        import net.xoetrope.awt.XButton;
012:        import net.xoetrope.awt.XPanel;
013:        import net.xoetrope.xui.helper.XuiUtilities;
014:
015:        /**
016:         * An outlook style roll-up bar. The methods are modelled on the JTabbedPane
017:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
018:         * the GNU Public License (GPL), please see license.txt for more details. If
019:         * you make commercial use of this software you must purchase a commercial
020:         * license from Xoetrope.</p>
021:         * $Revision: 1.3 $
022:         */
023:        public class XRollupBar extends XPanel implements  ActionListener {
024:            protected XPanel contentPane;
025:            protected int selIdx;
026:            protected CardLayout cardManager;
027:
028:            /**
029:             * Create a new button panel
030:             */
031:            public XRollupBar() {
032:                setLayout(new GridLayout(0, 1));
033:
034:                contentPane = new XPanel();
035:                contentPane.setLayout(cardManager = new CardLayout());
036:                add(contentPane);
037:
038:                selIdx = 0;
039:            }
040:
041:            /**
042:             * Add a new button.
043:             * The add method could not be overloaded so this method adds does the
044:             * equivalent.
045:             * @param comp the new button component
046:             * @return the new component
047:             */
048:            public Component add(Component comp) {
049:                String title = null;
050:                try {
051:                    Hashtable attribs = XuiBuilder.getCurrentAttributes();
052:                    title = XuiUtilities.translate(currentProject,
053:                            (String) attribs.get("title"));
054:                } catch (Exception ex) {
055:                }
056:                addbutton(title, comp);
057:                return comp;
058:            }
059:
060:            /**
061:             * Add a new button.
062:             * The add method could not be overloaded so this method adds does the
063:             * equivalent.
064:             * @param name the name/caption of the button component
065:             * @param panel the content
066:             */
067:            public void addbutton(String name, Component panel) {
068:                XButton newBtn = new XButton();
069:                newBtn.setText(name);
070:                add(newBtn);
071:                contentPane.add(panel, name);
072:                newBtn.addActionListener(this );
073:            }
074:
075:            /**
076:             * Get the button component at the specified index, skips over the expanded panel
077:             * @param index the button index
078:             * @return the button component
079:             */
080:            public XButton getButton(int index) {
081:                if (index >= (getComponentCount() - 1))
082:                    return null;
083:
084:                Component comp = getComponent(index);
085:                if (comp instanceof  XPanel)
086:                    comp = getComponent(++index);
087:                return (XButton) comp;
088:            }
089:
090:            /**
091:             * Get a button's background color
092:             * @param index the button index
093:             * @return the color
094:             */
095:            public Color getBackgroundAt(int index) {
096:                return getButton(index).getBackground();
097:            }
098:
099:            /**
100:             * Get a button's foreground color
101:             * @param index the button index
102:             * @return the color
103:             */
104:            public Color getForegroundAt(int index) {
105:                return getButton(index).getForeground();
106:            }
107:
108:            /**
109:             * Get the number of buttons
110:             * @return the number of buttons
111:             */
112:            public int getButtonCount() {
113:                return getComponentCount() - 1;
114:            }
115:
116:            /**
117:             * Get the index of the selected button
118:             * @return the selection index
119:             */
120:            public int getSelectedIndex() {
121:                return selIdx;
122:            }
123:
124:            /**
125:             * Get the title of the button at the specified index
126:             * @param index the button index
127:             * @return the button text/title
128:             */
129:            public String getTitleAt(int index) {
130:                return getButton(index).getText();
131:            }
132:
133:            /**
134:             * Set the button background color
135:             * @param index the button index
136:             * @param clr the new colr
137:             */
138:            public void setBackgroundAt(int index, Color clr) {
139:                getButton(index).setBackground(clr);
140:            }
141:
142:            /**
143:             * Set the foreground color
144:             * @param index the button index
145:             * @param clr the new color
146:             */
147:            public void setForegroundAt(int index, Color clr) {
148:                getComponent(index).setForeground(clr);
149:            }
150:
151:            /**
152:             * Select a button
153:             * @param index the button index
154:             */
155:            public void setSelectedIndex(int index) {
156:                selIdx = index;
157:                XButton comp = getButton(selIdx);
158:                cardManager.show(contentPane, comp.getText());
159:                repaint();
160:            }
161:
162:            /**
163:             * Set a button's title
164:             * @param index the button index
165:             * @param str the text for the button
166:             */
167:            public void setTitleAt(int index, String str) {
168:                XButton btn = getButton(index);
169:                String oldText = btn.getText();
170:                int numComponents = contentPane.getComponentCount();
171:                for (int i = 0; i < numComponents; i++) {
172:                    if (contentPane.getComponent(i).getName().equals(oldText))
173:                        contentPane.getComponent(i).setName(str);
174:                }
175:                btn.setText(str);
176:            }
177:
178:            //-Action listener methods-----------------------------------------------------
179:            /**
180:             * Invoked when a mouse button has been pressed on a component.
181:             * @param e the event
182:             */
183:            public void actionPerformed(ActionEvent e) {
184:                XButton comp = (XButton) e.getSource();
185:                int numComps = getComponentCount();
186:                int contentIdx = -1;
187:                for (int i = 0; i < numComps; i++) {
188:                    Component compi = getComponent(i);
189:                    if (compi == comp)
190:                        selIdx = i;
191:                    else if (compi == contentPane)
192:                        contentIdx = i;
193:                }
194:
195:                // Reduce the index as the content pane is about to be moved down.
196:                if (contentIdx < selIdx)
197:                    selIdx--;
198:
199:                remove(contentPane);
200:                add(contentPane, selIdx + 1);
201:
202:                cardManager.show(contentPane, comp.getText());
203:                doLayout();
204:            }
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.