Source Code Cross Referenced for Button.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 thinwire.ui.event.ActionListener;
031:        import thinwire.util.ImageInfo;
032:
033:        /**
034:         * A Button is a component that typically causes an action when activated.
035:         * <p>
036:         * <b>Example:</b> <br>
037:         * <img src="doc-files/Button-1.png"> <br>
038:         * 
039:         * <pre>
040:         * Button b = new Button(&quot;Click Me!&quot;);
041:         * b.setBounds(20, 20, 150, 30);
042:         * b.addActionListener(Button.ACTION_CLICK, new ActionListener() {
043:         *     public void actionPerformed(ActionEvent e) {
044:         *         ((Button) e.getSource()).setText(&quot;You Clicked Me!&quot;);
045:         *     }
046:         * });
047:         * 
048:         * Dialog d = new Dialog(&quot;Button Test&quot;);
049:         * d.setBounds(20, 20, 200, 100);
050:         * d.getChildren().add(b);
051:         * d.setVisible(true);
052:         * </pre>
053:         * 
054:         * </p>
055:         * <p>
056:         * <b>Keyboard Navigation:</b><br>
057:         * <table border="1">
058:         * <tr>
059:         * <td>KEY</td>
060:         * <td>RESPONSE</td>
061:         * <td>NOTE</td>
062:         * </tr>
063:         * <tr>
064:         * <td>Space</td>
065:         * <td>Fires ActionEvent( action = Button.ACTION_CLICK )</td>
066:         * <td>Only if the component has focus.</td>
067:         * </tr>
068:         * <tr>
069:         * <td>Enter</td>
070:         * <td>Fires ActionEvent( action = Button.ACTION_CLICK )</td>
071:         * <td> Only if the 'standard' property is set to 'true' and ANY component in the Window has focus. The only exception is if you are
072:         * focused on a component that has it's own behavior for for the Enter key, in which case Ctrl-Enter may be used. </td>
073:         * </tr>
074:         * <tr>
075:         * <td>Ctrl-Enter</td>
076:         * <td>Fires ActionEvent( action=Button.ACTION_CLICK )</td>
077:         * <td>Only if the 'standard' property is set to 'true' and ANY component in the Window has focus.</td>
078:         * </tr>
079:         * </table>
080:         * </p>
081:         * @author Joshua J. Gertzen
082:         */
083:        public class Button extends AbstractTextComponent implements 
084:                ImageComponent {
085:            public static final String PROPERTY_STANDARD = "standard";
086:
087:            private boolean standard;
088:            private ImageInfo imageInfo = new ImageInfo(null);
089:
090:            /**
091:             * Constructs a new Button with no text or image.
092:             */
093:            public Button() {
094:                this (null, null);
095:            }
096:
097:            /**
098:             * Constructs a new Button with the specified text and no image.
099:             * @param text the text to display on the Button.
100:             */
101:            public Button(String text) {
102:                this (text, null);
103:            }
104:
105:            /**
106:             * Constructs a new Button with the specified text and image.
107:             * @param text the text to display on the Button.
108:             * @param image the name of a image file resource to display on the Button.
109:             */
110:            public Button(String text, String image) {
111:                setText(text);
112:                setImage(image);
113:            }
114:
115:            public String getImage() {
116:                return imageInfo.getName();
117:            }
118:
119:            public void setImage(String image) {
120:                String oldImage = this .imageInfo.getName();
121:                imageInfo = new ImageInfo(image);
122:                firePropertyChange(this , PROPERTY_IMAGE, oldImage,
123:                        this .imageInfo.getName());
124:            }
125:
126:            public ImageInfo getImageInfo() {
127:                return imageInfo;
128:            }
129:
130:            /**
131:             * Returns whether the button is the standard button (i.e. default).
132:             * @return true if this button is the standard button
133:             */
134:            public final boolean isStandard() {
135:                return standard;
136:            }
137:
138:            /**
139:             * Sets whether this button is the standard button.
140:             * There can only be a single standard button per <code>Window</code>,
141:             * therefore setting this property to true will result in
142:             * the 'standard' property of the current standard button to be set to false. 
143:             * @param standard true to make this the standard button, false otherwise.
144:             * @throws UnsupportedOperationException if this Button's parent is not a Container.
145:             */
146:            public final void setStandard(boolean standard) {
147:                boolean oldStandard = this .standard;
148:                this .standard = standard;
149:                Object o = getParent();
150:
151:                if (o instanceof  AbstractContainer) {
152:                    if (standard && !oldStandard) {
153:                        ((AbstractContainer) o)
154:                                .updateStandardButton(this , true);
155:                    } else if (!standard && oldStandard) {
156:                        ((AbstractContainer) o).updateStandardButton(this ,
157:                                false);
158:                    }
159:                }
160:
161:                firePropertyChange(this, PROPERTY_STANDARD, oldStandard,
162:                        standard);
163:            }
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.