Source Code Cross Referenced for WingCheckBox.java in  » Web-Framework » wingS » com » javujavu » javux » 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 » Web Framework » wingS » com.javujavu.javux.wings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *	Javu WingS - Lightweight Java Component Set
003:         *	Copyright (c) 2005-2007 Krzysztof A. Sadlocha
004:         *	e-mail: ksadlocha@programics.com
005:         *
006:         *	This library is free software; you can redistribute it and/or
007:         *	modify it under the terms of the GNU Lesser General Public
008:         *	License as published by the Free Software Foundation; either
009:         *	version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *	This library is distributed in the hope that it will be useful,
012:         *	but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *	Lesser General Public License for more details.
015:         *
016:         *	You should have received a copy of the GNU Lesser General Public
017:         *	License along with this library; if not, write to the Free Software
018:         *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         */
020:
021:        package com.javujavu.javux.wings;
022:
023:        import java.awt.ItemSelectable;
024:        import java.awt.event.ItemEvent;
025:
026:        /**
027:         * An implementation of a check box.
028:         * This component has 3 looks: checkbox, radio button and toggle button
029:         *
030:         * <br>
031:         * <b>This class is thread safe.</b>
032:         **/
033:        public class WingCheckBox extends WingButton implements  ItemSelectable {
034:            protected int look;
035:            protected boolean selected;
036:            protected RadioGroup group;
037:
038:            protected Style stOnNormal;
039:            protected Style stOnPressed;
040:            protected Style stOnFocused;
041:            protected Style stOnHover;
042:            protected Style stOnDisabled;
043:
044:            /**
045:             * Creates a check box with no label and look CHECKBOX.
046:             */
047:            public WingCheckBox() {
048:                this (CHECKBOX);
049:            }
050:
051:            /**
052:             * Creates a check box with no label and specified look.
053:             * WingCheckBox.CHECKBOX, WingCheckBox.RADIO and WingCheckBox.TOGGLE
054:             * is allowed.
055:             * @param look look of the checkbox
056:             */
057:            public WingCheckBox(int look) {
058:                this (null, look);
059:            }
060:
061:            /**
062:             * Creates a check box with label <code>label</code> and look CHECKBOX.
063:             * @param label label
064:             */
065:            public WingCheckBox(Object label) {
066:                this (label, CHECKBOX);
067:            }
068:
069:            /**
070:             * Creates a check box with label <code>label</code> and specified look.
071:             * WingCheckBox.CHECKBOX, WingCheckBox.RADIO and WingCheckBox.TOGGLE
072:             * is allowed.
073:             * @param look look of the checkbox
074:             * @param label label
075:             */
076:            public WingCheckBox(Object label, int look) {
077:                super (label);
078:                this .look = look;
079:                if (look != TOGGLE)
080:                    setHorizontalAlignment(LEFT);
081:            }
082:
083:            /**
084:             * Loads skin resources.<br>
085:             * <pre>
086:             * styles:
087:             * [optional styleID.]&lt;look&gt;.normal
088:             * [optional styleID.]&lt;look&gt;.pressed
089:             * [optional styleID.]&lt;look&gt;.focused
090:             * [optional styleID.]&lt;look&gt;.hover
091:             * [optional styleID.]&lt;look&gt;.disabled
092:             * [optional styleID.]&lt;look&gt;.on.normal
093:             * [optional styleID.]&lt;look&gt;.on.pressed
094:             * [optional styleID.]&lt;look&gt;.on.focused
095:             * [optional styleID.]&lt;look&gt;.on.hover
096:             * [optional styleID.]&lt;look&gt;.on.disabled
097:             *
098:             * where &lt;look&gt;= "checkbox" or "radio" or "button"
099:             * </pre>
100:             * @see Style
101:             * @see WingSkin
102:             */
103:            public void loadSkin() {
104:                String type = (look == CHECKBOX) ? "checkbox"
105:                        : (look == RADIO) ? "radio" : "button";
106:
107:                String idt = WingSkin.catKeys(styleId, type);
108:
109:                stNormal = WingSkin.getStyle(idt, null, NORMAL, null);
110:                stPressed = WingSkin.getStyle(idt, null, PRESSED, stNormal);
111:                stFocused = WingSkin.getStyle(idt, null, FOCUSED, stNormal);
112:                stHover = WingSkin.getStyle(idt, null, HOVER, stNormal);
113:                stDisabled = WingSkin.getStyle(idt, null, DISABLED, stNormal);
114:
115:                stOnNormal = WingSkin
116:                        .getStyle(idt, null, ON | NORMAL, stNormal);
117:                stOnPressed = WingSkin.getStyle(idt, null, ON | PRESSED,
118:                        stOnNormal);
119:                stOnFocused = WingSkin.getStyle(idt, null, ON | FOCUSED,
120:                        stOnNormal);
121:                stOnHover = WingSkin
122:                        .getStyle(idt, null, ON | HOVER, stOnNormal);
123:                stOnDisabled = WingSkin.getStyle(idt, null, ON | DISABLED,
124:                        stDisabled);
125:            }
126:
127:            /**
128:             * Returns the style representing current checkbox state
129:             * @return current style representing checkbox state
130:             */
131:            public Style getStyle() {
132:                return (selected) ? ((!isEnabled()) ? stOnDisabled
133:                        : ((pressed && hover) || keyPressed) ? stOnPressed
134:                                : (hover) ? stOnHover : (focused) ? stOnFocused
135:                                        : stOnNormal)
136:                        : ((!isEnabled()) ? stDisabled
137:                                : ((pressed && hover) || keyPressed) ? stPressed
138:                                        : (hover) ? stHover
139:                                                : (focused) ? stFocused
140:                                                        : stNormal);
141:            }
142:
143:            protected void buttonAction(int eventModifiers) {
144:                if (group == null || !selected)
145:                    setSelected(!selected, true);
146:            }
147:
148:            /**
149:             * Sets the selected state of the checkbox.
150:             * @param select  true if the checkbox is selected, otherwise false
151:             **/
152:            public void setSelected(boolean select) {
153:                setSelected(select, false);
154:            }
155:
156:            protected void setSelected(boolean select, boolean notify) {
157:                boolean oldSelected = selected;
158:                selected = select;
159:                if (oldSelected != select) {
160:                    repaint();
161:                    if (group != null)
162:                        group.setSelected(this , select);
163:                    if (notify)
164:                        wingProcessItemEvent(new ItemEvent(this ,
165:                                ItemEvent.ITEM_STATE_CHANGED, this ,
166:                                (select) ? ItemEvent.SELECTED
167:                                        : ItemEvent.DESELECTED));
168:                }
169:            }
170:
171:            /**
172:             * Returns the state of the checkbox. True if the
173:             * checkbox is selected, false if it's not.
174:             * @return true if the checkbox is selected, otherwise false
175:             **/
176:            public boolean isSelected() {
177:                return selected;
178:            }
179:
180:            /**
181:             * Returns an array (length 1) containing the label or
182:             * <code>null</code> if the checkbox is not selected.
183:             *
184:             * @return an array containing 1 Object: the label of the checkbox,
185:             *         if the item is selected; otherwise <code>null</code>
186:             **/
187:            public Object[] getSelectedObjects() {
188:                if (selected) {
189:                    Object[] items = { label };
190:                    return items;
191:                }
192:                return null;
193:            }
194:
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.