Source Code Cross Referenced for SLabel.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.LabelCG;
016:
017:        /**
018:         * Display area for a short text string or an image, or both.
019:         * <p/>
020:         * You can specify where in the label's display area  the label's contents
021:         * are aligned by setting the vertical and horizontal alignment.
022:         * You can also specify the position of the text relative to the image.
023:         *
024:         * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
025:         */
026:        public class SLabel extends SComponent {
027:
028:            protected String text;
029:            protected SIcon icon = null;
030:            protected SIcon disabledIcon = null;
031:            protected int verticalTextPosition = SConstants.CENTER;
032:            protected int horizontalTextPosition = SConstants.RIGHT;
033:            protected int iconTextGap = 4;
034:            protected boolean wordWrap;
035:
036:            /**
037:             * Creates a new <code>SLabel</code> instance with the specified text
038:             * (left alligned) and no icon.
039:             *
040:             * @param text The text to be displayed by the label.
041:             */
042:            public SLabel(String text) {
043:                this (text, null, SConstants.LEFT);
044:            }
045:
046:            /**
047:             * Creates a new <code>SLabel</code> instance with no text and no icon.
048:             */
049:            public SLabel() {
050:                this ((String) null);
051:            }
052:
053:            /**
054:             * Creates a new <code>SLabel</code> instance with the specified icon
055:             * (left alligned) and no text.
056:             *
057:             * @param icon The image to be displayed by the label.
058:             */
059:            public SLabel(SIcon icon) {
060:                this (icon, SConstants.LEFT);
061:            }
062:
063:            /**
064:             * Creates a new <code>SLabel</code> instance with the specified icon
065:             * (alligned as specified) and no text.
066:             *
067:             * @param icon                The image to be displayed by the label.
068:             * @param horizontalAlignment One of the following constants defined in
069:             *                            <code>SConstants</code>:
070:             *                            <code>LEFT</code>, <code>CENTER</code>, <code>RIGHT</code>.
071:             * @see SConstants
072:             */
073:            public SLabel(SIcon icon, int horizontalAlignment) {
074:                this (null, icon, horizontalAlignment);
075:            }
076:
077:            /**
078:             * Creates a new <code>SLabel</code> instance with the specified icon
079:             * and the specified text (left alligned).
080:             *
081:             * @param text The text to be displayed by the label.
082:             * @param icon The image to be displayed by the label.
083:             */
084:            public SLabel(String text, SIcon icon) {
085:                this (text, icon, SConstants.LEFT);
086:            }
087:
088:            /**
089:             * Creates a new <code>SLabel</code> instance with the specified icon
090:             * and the specified text (alligned as specified).
091:             *
092:             * @param text                The text to be displayed by the label.
093:             * @param icon                The image to be displayed by the label.
094:             * @param horizontalAlignment One of the following constants defined in
095:             *                            <code>SConstants</code>:
096:             *                            <code>LEFT</code>, <code>CENTER</code>, <code>RIGHT</code>.
097:             * @see SConstants
098:             */
099:            public SLabel(String text, SIcon icon, int horizontalAlignment) {
100:                setText(text);
101:                setIcon(icon);
102:                setHorizontalAlignment(horizontalAlignment);
103:            }
104:
105:            /**
106:             * Creates a new <code>SLabel</code> instance with the specified text
107:             * (alligned as specified) and no icon.
108:             *
109:             * @param text                The text to be displayed by the label.
110:             * @param horizontalAlignment One of the following constants defined in
111:             *                            <code>SConstants</code>:
112:             *                            <code>LEFT</code>, <code>CENTER</code>, <code>RIGHT</code>.
113:             * @see SConstants
114:             */
115:            public SLabel(String text, int horizontalAlignment) {
116:                this (text, null, horizontalAlignment);
117:            }
118:
119:            /**
120:             * Returns the horizontal position of the lable's text
121:             *
122:             * @return the position
123:             * @see SConstants
124:             * @see #setHorizontalTextPosition
125:             */
126:            public int getHorizontalTextPosition() {
127:                return horizontalTextPosition;
128:            }
129:
130:            /**
131:             * Sets the horizontal position of the lable's text, relative to its icon.
132:             * <p/>
133:             * The default value of this property is CENTER.
134:             *
135:             * @param textPosition One of the following constants defined in
136:             *                     <code>SConstants</code>:
137:             *                     <code>LEFT</code>, <code>CENTER</code>, <code>RIGHT</code>.
138:             */
139:            public void setHorizontalTextPosition(int textPosition) {
140:                reloadIfChange(horizontalTextPosition, textPosition);
141:                horizontalTextPosition = textPosition;
142:            }
143:
144:            /**
145:             * Sets the vertical position of the lable's text, relative to its icon.
146:             * <p/>
147:             * The default value of this property is CENTER.
148:             *
149:             * @param textPosition One of the following constants defined in
150:             *                     <code>SConstants</code>:
151:             *                     <code>TOP</code>, <code>CENTER</code>, <code>BOTTOM</code>.
152:             */
153:            public void setVerticalTextPosition(int textPosition) {
154:                reloadIfChange(verticalTextPosition, textPosition);
155:                verticalTextPosition = textPosition;
156:            }
157:
158:            /**
159:             * Returns the vertical position of the label's text
160:             *
161:             * @return the position
162:             * @see SConstants
163:             * @see #setVerticalTextPosition
164:             */
165:            public int getVerticalTextPosition() {
166:                return verticalTextPosition;
167:            }
168:
169:            /**
170:             * Defines the icon the component will display.
171:             * @param i
172:             */
173:            public void setIcon(SIcon i) {
174:                if (isDifferent(icon, i)) {
175:                    // do reload if previous text was null
176:                    if (isUpdatePossible() && icon != null
177:                            && SLabel.class.isAssignableFrom(getClass()))
178:                        update(((LabelCG) getCG()).getIconUpdate(this , i));
179:                    else
180:                        reload();
181:                    icon = i;
182:                }
183:            }
184:
185:            /**
186:             * Returns the icon the label displays.
187:             * @return the icon
188:             */
189:            public SIcon getIcon() {
190:                return icon;
191:            }
192:
193:            /**
194:             * Set the icon that will be displayed if the label is disabled.
195:             * @param i
196:             */
197:            public void setDisabledIcon(SIcon i) {
198:                reloadIfChange(disabledIcon, i);
199:                disabledIcon = i;
200:            }
201:
202:            /**
203:             * Returns the icon that is displayed when the label is disabled.
204:             * @return the diabledIcon
205:             */
206:            public SIcon getDisabledIcon() {
207:                return disabledIcon;
208:            }
209:
210:            /**
211:             * Returns the text of the label
212:             * @return the text
213:             */
214:            public String getText() {
215:                return text;
216:            }
217:
218:            /**
219:             * Sets the text of the label. Nothing will be displayed if the text is an empty string or null.
220:             *
221:             * @param t The new text
222:             */
223:            public void setText(String t) {
224:                if (isDifferent(text, t)) {
225:                    // do reload if previous text was null
226:                    if (isUpdatePossible() && text != null
227:                            && SLabel.class.isAssignableFrom(getClass()))
228:                        update(((LabelCG) getCG()).getTextUpdate(this , t));
229:                    else
230:                        reload();
231:                    text = t;
232:                }
233:            }
234:
235:            /**
236:             * Determiens if the label text word wrap inside the browser. Defaults to <code>false</code> (Swing).
237:             * @return <code>false</code> if the label should not word wrap an be in line as in Swing.
238:             */
239:            public boolean isWordWrap() {
240:                return wordWrap;
241:            }
242:
243:            /**
244:             * Defines if the label is allowed to wrap.
245:             * @param wordWrap Set to <code>true</code> if you want labels to allow to break into more lines than passed.
246:             */
247:            public void setWordWrap(boolean wordWrap) {
248:                if (this .wordWrap != wordWrap) {
249:                    this .wordWrap = wordWrap;
250:                    reload();
251:                }
252:            }
253:
254:            /**
255:             * Returns the amount of space between the text and the icon
256:             * displayed in this label.
257:             *
258:             * @return an int equal to the number of pixels between the text
259:             *         and the icon.
260:             * @see #setIconTextGap
261:             */
262:            public int getIconTextGap() {
263:                return iconTextGap;
264:            }
265:
266:            /**
267:             * If both the icon and text properties are set, this property
268:             * defines the space between them.
269:             * <p>
270:             * The default value of this property is 4 pixels.
271:             * <p>
272:             *
273:             * @see #getIconTextGap
274:             */
275:            public void setIconTextGap(int iconTextGap) {
276:                reloadIfChange(this .iconTextGap, iconTextGap);
277:                this .iconTextGap = iconTextGap;
278:            }
279:
280:            public void setCG(LabelCG cg) {
281:                super.setCG(cg);
282:            }
283:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.