Source Code Cross Referenced for TabSheet.java in  » Web-Framework » ThinWire » thinwire » ui » 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 » Web Framework » ThinWire » thinwire.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        #IFNDEF ALT_LICENSE
003:                                   ThinWire(R) RIA Ajax Framework
004:                         Copyright (C) 2003-2007 Custom Credit Systems
005:
006:          This library is free software; you can redistribute it and/or modify it under
007:          the terms of the GNU Lesser General Public License as published by the Free
008:          Software Foundation; either version 2.1 of the License, or (at your option) any
009:          later version.
010:
011:          This library is distributed in the hope that it will be useful, but WITHOUT ANY
012:          WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
013:          PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
014:
015:          You should have received a copy of the GNU Lesser General Public License along
016:          with this library; if not, write to the Free Software Foundation, Inc., 59
017:          Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:
019:          Users who would rather have a commercial license, warranty or support should
020:          contact the following company who invented, built and supports the technology:
021:          
022:                        Custom Credit Systems, Richardson, TX 75081, USA.
023:           	            email: info@thinwire.com    ph: +1 (888) 644-6405
024:         	                        http://www.thinwire.com
025:        #ENDIF
026:         [ v1.2_RC2 ] 
027:         */
028:        package thinwire.ui;
029:
030:        import java.util.List;
031:
032:        import thinwire.util.ImageInfo;
033:
034:        /**
035:         * A TabSheet is a Panel that can be layered, so that a user can switch between
036:         * tab sheets.
037:         * <p>
038:         * <b>Example:</b> <br>
039:         * <img src="doc-files/TabFolder-1.png"> <br>
040:         * 
041:         * <pre>
042:         * Dialog dlg = new Dialog(&quot;TabFolder Test&quot;);
043:         * dlg.setBounds(25, 25, 600, 400);
044:         * 
045:         * TabSheet tSheet1 = new TabSheet(&quot;Sheet 1&quot;);
046:         * TabSheet tSheet2 = new TabSheet(&quot;Sheet 2&quot;);
047:         * 
048:         * TabFolder tFolder = new TabFolder();
049:         * tFolder.setBounds(50, 25, 500, 300);
050:         * tFolder.getChildren().add(tSheet1);
051:         * tFolder.getChildren().add(tSheet2);
052:         * 
053:         * TextField tf = new TextField();
054:         * tf.setBounds(25, 25, 150, 20);
055:         * tSheet2.getChildren().add(tf);
056:         * 
057:         * Button firstButton = new Button(&quot;Change Tab Title 1&quot;);
058:         * firstButton.setBounds(50, 50, 150, 30);
059:         * firstButton.addActionListener(Button.ACTION_CLICK, new ActionListener() {
060:         *     public void actionPerformed(ActionEvent ev) {
061:         *         ((TabSheet) ((Button) ev.getSource()).getParent()).setText(&quot;New Title 1&quot;);
062:         *     }
063:         * });
064:         * tSheet1.getChildren().add(firstButton);
065:         * dlg.getChildren().add(tFolder);
066:         * dlg.setVisible(true);
067:         * </pre>
068:         * 
069:         * </p>
070:         * <p>
071:         * <b>Keyboard Navigation:</b><br>
072:         * <table border="1">
073:         * <tr>
074:         * <td>KEY</td>
075:         * <td>RESPONSE</td>
076:         * <td>NOTE</td>
077:         * </tr>
078:         * </table>
079:         * </p>
080:         * 
081:         * @author Joshua J. Gertzen
082:         */
083:        public class TabSheet extends AbstractContainer<Component> implements 
084:                TextComponent, ImageComponent {
085:            private String text = "";
086:            private boolean allowBoundsChange;
087:            private ImageInfo imageInfo = new ImageInfo(null);
088:
089:            /**
090:             * Construct a new TabSheet with no text.
091:             */
092:            public TabSheet() {
093:                this (null, null);
094:            }
095:
096:            /**
097:             * Creates a new TabSheet with the specified text.
098:             * @param text the text to dispaly on the tab part of the TabSheet.
099:             */
100:            public TabSheet(String text) {
101:                this (text, null);
102:            }
103:
104:            public TabSheet(String text, String image) {
105:                setText(text);
106:                setImage(image);
107:            }
108:
109:            public String getImage() {
110:                return imageInfo.getName();
111:            }
112:
113:            public void setImage(String image) {
114:                String oldImage = this .imageInfo.getName();
115:                imageInfo = new ImageInfo(image);
116:                firePropertyChange(this , PROPERTY_IMAGE, oldImage,
117:                        this .imageInfo.getName());
118:            }
119:
120:            public ImageInfo getImageInfo() {
121:                return imageInfo;
122:            }
123:
124:            /**
125:             * Returns the text displayed on the tab part of the TabSheet.
126:             * @return the text displayed on the tab part of the TabSheet.
127:             */
128:            public String getText() {
129:                return text;
130:            }
131:
132:            /**
133:             * Sets the text that is displayed on the tab part of the TabSheet.
134:             * @param text the text to be shown.
135:             */
136:            public void setText(String text) {
137:                String oldText = this .text;
138:                this .text = text == null ? "" : text;
139:                firePropertyChange(this , PROPERTY_TEXT, oldText, this .text);
140:            }
141:
142:            void boundsChanged(int x, int y, int width, int height) {
143:                try {
144:                    allowBoundsChange = true;
145:                    super .setBounds(x, y, width, height);
146:                } finally {
147:                    allowBoundsChange = false;
148:                }
149:            }
150:
151:            public int getInnerHeight() {
152:                int innerHeight = super .getInnerHeight()
153:                        - TabFolder.TABS_HEIGHT;
154:                return innerHeight < 0 ? 0 : innerHeight;
155:            }
156:
157:            public void setWidth(int width) {
158:                if (allowBoundsChange) {
159:                    super .setWidth(width);
160:                } else {
161:                    TabFolder tf = (TabFolder) getParent();
162:
163:                    if (tf == null) {
164:                        throw new IllegalStateException(
165:                                "You must first add a TabSheet to a TabFolder before you can set the 'width' property");
166:                    } else {
167:                        tf.setWidth(width);
168:                    }
169:                }
170:            }
171:
172:            public void setHeight(int height) {
173:                if (allowBoundsChange) {
174:                    super .setHeight(height);
175:                } else {
176:                    TabFolder tf = (TabFolder) getParent();
177:
178:                    if (tf == null) {
179:                        throw new IllegalStateException(
180:                                "You must first add a TabSheet to a TabFolder before you can set the 'height' property");
181:                    } else {
182:                        tf.setHeight(height);
183:                    }
184:                }
185:            }
186:
187:            public void setX(int x) {
188:                if (allowBoundsChange) {
189:                    super .setX(x);
190:                } else {
191:                    TabFolder tf = (TabFolder) getParent();
192:
193:                    if (tf == null) {
194:                        throw new IllegalStateException(
195:                                "You must first add a TabSheet to a TabFolder before you can set the 'x' property");
196:                    } else {
197:                        tf.setX(x);
198:                    }
199:                }
200:            }
201:
202:            public void setY(int y) {
203:                if (allowBoundsChange) {
204:                    super .setY(y);
205:                } else {
206:                    TabFolder tf = (TabFolder) getParent();
207:
208:                    if (tf == null) {
209:                        throw new IllegalStateException(
210:                                "You must first add a TabSheet to a TabFolder before you can set the 'y' property");
211:                    } else {
212:                        tf.setY(y);
213:                    }
214:                }
215:            }
216:
217:            public void setVisible(boolean visible) {
218:                boolean oldVisible = isVisible();
219:                super .setVisible(visible);
220:
221:                if (oldVisible != visible) {
222:                    TabFolder tf = (TabFolder) getParent();
223:
224:                    if (tf != null) {
225:                        List<TabSheet> l = tf.getChildren();
226:                        int index = l.indexOf(this );
227:
228:                        if (index == tf.getCurrentIndex()) {
229:                            if (index + 1 < l.size()) {
230:                                index++;
231:                            } else if (index > 0) {
232:                                index--;
233:                            } else {
234:                                index = -1;
235:                            }
236:
237:                            tf.setCurrentIndex(index);
238:                        }
239:                    }
240:                }
241:            }
242:
243:            /**
244:             * This property is unsupported by the TabSheet component.
245:             * @throws UnsupportedOperationException indicating this property is not supported by TabSheet.
246:             */
247:            public Object getLimit() {
248:                throw new UnsupportedOperationException(
249:                        getStandardPropertyUnsupportedMsg(PROPERTY_LIMIT, true));
250:            }
251:
252:            /**
253:             * This property is unsupported by the TabSheet component.
254:             * @throws UnsupportedOperationException indicating this property is not supported by TabSheet.
255:             */
256:            public Component setLimit(Object limit) {
257:                throw new UnsupportedOperationException(
258:                        getStandardPropertyUnsupportedMsg(PROPERTY_LIMIT, false));
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.