Source Code Cross Referenced for XRadioButton.java in  » XML-UI » XUI » net » xoetrope » swing » 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 » XUI » net.xoetrope.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.swing;
002:
003:        import java.util.Enumeration;
004:
005:        import javax.swing.ButtonGroup;
006:        import javax.swing.JRadioButton;
007:
008:        import net.xoetrope.xui.XAttributedComponent;
009:        import net.xoetrope.xui.XRadioButtonGroup;
010:        import net.xoetrope.xui.XRadioHolder;
011:        import net.xoetrope.xui.XStateHolder;
012:        import net.xoetrope.xui.XTextHolder;
013:        import net.xoetrope.xui.XValueHolder;
014:
015:        /**
016:         * A wrapper for the JRadioButton class
017:         * <p>Copyright (c) Xoetrope Ltd., 1998-2004<br>
018:         * License:      see license.txt
019:         * $Revision: 1.15 $
020:         */
021:        public class XRadioButton extends JRadioButton implements  XStateHolder,
022:                XValueHolder, XTextHolder, XRadioHolder, XAttributedComponent,
023:                XRadioButtonGroup {
024:            ButtonGroup buttonGroup;
025:            Object value;
026:
027:            public XRadioButton() {
028:            }
029:
030:            /**
031:             * Create a new checkbox group and adds this radio button top the new group
032:             * @return the new group
033:             */
034:            public Object createGroup() {
035:                buttonGroup = new ButtonGroup();
036:                setRadioButtonGroup(buttonGroup);
037:                return buttonGroup;
038:            }
039:
040:            /**
041:             * Set the button group
042:             * @param grp the group control this radio button
043:             */
044:            public void setRadioButtonGroup(Object grp) {
045:                buttonGroup = (ButtonGroup) grp;
046:                buttonGroup.add(this );
047:            }
048:
049:            /**
050:             * Gets the group controlling this radio button
051:             * @return the ButtonGroup
052:             */
053:            public Object getRadioButtonGroup() {
054:                return buttonGroup;
055:            }
056:
057:            /**
058:             * Gets the selected radio button
059:             * @return the selected radio button
060:             */
061:            public Object getSelectedObject()
062:  {
063:    if ( buttonGroup != null ) {
064:      Enumeration enum = buttonGroup.getElements();
065:      while ( enum.hasMoreElements()) {
066:        XRadioButton rb = (XRadioButton)enum.nextElement();
067:        if ( rb.isSelected())
068:          return rb;
069:      }
070:    }
071:    return null;
072:  }
073:
074:            /**
075:             * Select an item
076:             * @param i the index of the item to select
077:             */
078:            public void setSelectedObject( Object object )
079:  {
080:    if ( buttonGroup != null ) {
081:      Enumeration enum = buttonGroup.getElements();
082:      while ( enum.hasMoreElements()) {
083:        XRadioButton rb = (XRadioButton)enum.nextElement();
084:        if ( rb.getValue().equals( object ))
085:          rb.setSelected( true );
086:      }
087:    }
088:  }
089:
090:            /**
091:             * Selects this radio button
092:             */
093:            public void setSelected() {
094:                setSelected(true);
095:                ButtonGroup cbGroup = (ButtonGroup) getRadioButtonGroup();
096:                cbGroup.setSelected(getModel(), true);
097:            }
098:
099:            /**
100:             * Adds the checkbox to the same group as this component.
101:             * @param cb the checkbox/radiobutton to be added to the group
102:             */
103:            public void associate(Object cb) {
104:                ((XRadioButton) cb).setRadioButtonGroup(getRadioButtonGroup());
105:            }
106:
107:            /**
108:             * Set one or more attributes of the component. Currently this handles the
109:             * attributes
110:             * <OL>
111:             * <LI>selected, value=true|false</LI>
112:             * <LI>alignment, values=left|right|center|leading|trailing</LI>
113:             * </OL>
114:             * @param attribName the attribute name
115:             * @param attribValue the attribute value
116:             */
117:            public void setAttribute(String attribName, String attribValue) {
118:                if (attribName.compareTo("selected") == 0) {
119:                    ButtonGroup cbGroup = (ButtonGroup) getRadioButtonGroup();
120:                    if (cbGroup == null)
121:                        createGroup();
122:                    if (attribValue.compareTo("true") == 0) {
123:                        setSelected(true);
124:                        cbGroup.setSelected(getModel(), true);
125:                    }
126:                } else if (attribName.toLowerCase().compareTo("alignment") == 0)
127:                    setHorizontalAlignment(XAlignmentHelper
128:                            .getAlignmentOption(attribValue));
129:            }
130:
131:            /**
132:             * Get the component state
133:             * @param the new component state
134:             */
135:            public Object getComponentState() {
136:                return new Boolean(isSelected());
137:            }
138:
139:            /**
140:             * Set the component state
141:             * @return the object state
142:             */
143:            public void setComponentState(Object o) {
144:                if (o != null) {
145:                    String objValue = o.toString();
146:                    boolean value = objValue.equals("1");
147:                    if (!value)
148:                        value |= objValue.equals("true");
149:                    setSelected(value);
150:                }
151:            }
152:
153:            /**
154:             * Get the radiobutton's value if it has one or else get the text
155:             * @return the value for this button
156:             */
157:            public Object getValue() {
158:                if (value != null)
159:                    return value;
160:
161:                return getText();
162:            }
163:
164:            /**
165:             * Set the value associated with this button
166:             * @param newValue the new button value
167:             */
168:            public void setValue(Object newValue) {
169:                value = newValue;
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.