Source Code Cross Referenced for STextField.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.TextFieldCG;
016:
017:        import javax.swing.event.EventListenerList;
018:        import java.awt.event.ActionEvent;
019:        import java.awt.event.ActionListener;
020:
021:        /**
022:         * Single-lined input component for text input which requires a surrounding {@link SForm} element.
023:         *
024:         * @author <a href="mailto:armin.haaf@mercatis.de">Armin Haaf</a>
025:         */
026:        public class STextField extends STextComponent {
027:
028:            /**
029:             * maximum columns shown
030:             */
031:            protected int columns = 12;
032:
033:            /**
034:             * maximum columns allowed
035:             */
036:            protected int maxColumns = -1;
037:
038:            /**
039:             * default action command to fire
040:             */
041:            protected String actionCommand;
042:
043:            // Flag to ensure that infinite loops do not occur with ActionEvents.
044:            private boolean firingActionEvent = false;
045:
046:            public STextField() {
047:            }
048:
049:            public STextField(String text) {
050:                super (text);
051:            }
052:
053:            /**
054:             * Sets the number of columns of the TextField.
055:             * @param c the number of columns 
056:             */
057:            public void setColumns(int c) {
058:                int oldColumns = columns;
059:                columns = c;
060:                if (columns != oldColumns)
061:                    reload();
062:            }
063:
064:            /**
065:             * Returns the number of columns of the TextField.
066:             * @return the number of columns
067:             */
068:            public int getColumns() {
069:                return columns;
070:            }
071:
072:            public void setMaxColumns(int mc) {
073:                int oldMaxColumns = maxColumns;
074:                maxColumns = mc;
075:                if (maxColumns != oldMaxColumns)
076:                    reload();
077:            }
078:
079:            public int getMaxColumns() {
080:                return maxColumns;
081:            }
082:
083:            public void setCG(TextFieldCG cg) {
084:                super .setCG(cg);
085:            }
086:
087:            /**
088:             * Sets the action commnand that should be included in the event
089:             * sent to action listeners.
090:             *
091:             * @param command a string containing the "command" that is sent
092:             *                to action listeners. The same listener can then
093:             *                do different things depending on the command it
094:             *                receives.
095:             */
096:            public void setActionCommand(String command) {
097:                actionCommand = command;
098:            }
099:
100:            /**
101:             * Returns the action commnand that is included in the event sent to
102:             * action listeners.
103:             *
104:             * @return the string containing the "command" that is sent
105:             *         to action listeners.
106:             */
107:            public String getActionCommand() {
108:                if (actionCommand == null)
109:                    return getText();
110:                return actionCommand;
111:            }
112:
113:            /**
114:             * Adds an ActionListener to the button.
115:             *
116:             * @param listener the ActionListener to be added
117:             */
118:            public void addActionListener(ActionListener listener) {
119:                addEventListener(ActionListener.class, listener);
120:            }
121:
122:            /**
123:             * Removes the supplied Listener from teh listener list
124:             */
125:            public void removeActionListener(ActionListener listener) {
126:                removeEventListener(ActionListener.class, listener);
127:            }
128:
129:            /**
130:             * Returns an array of all the <code>ActionListener</code>s added
131:             * to this AbstractButton with addActionListener().
132:             *
133:             * @return all of the <code>ActionListener</code>s added or an empty
134:             *         array if no listeners have been added
135:             */
136:            public ActionListener[] getActionListeners() {
137:                return (ActionListener[]) (getListeners(ActionListener.class));
138:            }
139:
140:            /**
141:             * Fire an ActionEvent at each registered listener.
142:             *
143:             * @param event the supplied ActionEvent
144:             */
145:            protected void fireActionPerformed(ActionEvent event) {
146:                // Guaranteed to return a non-null array
147:                Object[] listeners = getListenerList();
148:                ActionEvent e = null;
149:                // Process the listeners last to first, notifying
150:                // those that are interested in this event
151:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
152:                    if (listeners[i] == ActionListener.class) {
153:                        if (e == null) {
154:                            String actionCommand = event.getActionCommand();
155:                            if (actionCommand == null) {
156:                                actionCommand = getActionCommand();
157:                            }
158:                            e = new ActionEvent(this ,
159:                                    ActionEvent.ACTION_PERFORMED,
160:                                    actionCommand, event.getWhen(), event
161:                                            .getModifiers());
162:                        }
163:                        ((ActionListener) listeners[i + 1]).actionPerformed(e);
164:                    }
165:                }
166:            }
167:
168:            /**
169:             * Notify all listeners that have registered as ActionListeners if the
170:             * selected item has changed
171:             *
172:             * @see EventListenerList
173:             */
174:            protected void fireActionEvent() {
175:                if (!firingActionEvent) {
176:                    // Set flag to ensure that an infinite loop is not created
177:                    firingActionEvent = true;
178:
179:                    ActionEvent e = null;
180:
181:                    // Guaranteed to return a non-null array
182:                    Object[] listeners = getListenerList();
183:                    // Process the listeners last to first, notifying
184:                    // those that are interested in this event
185:                    for (int i = listeners.length - 2; i >= 0; i -= 2) {
186:                        if (listeners[i] == ActionListener.class) {
187:                            if (e == null)
188:                                e = new ActionEvent(this ,
189:                                        ActionEvent.ACTION_PERFORMED,
190:                                        getActionCommand());
191:                            ((ActionListener) listeners[i + 1])
192:                                    .actionPerformed(e);
193:                        }
194:                    }
195:                    firingActionEvent = false;
196:                }
197:            }
198:
199:            public void fireFinalEvents() {
200:                super.fireFinalEvents();
201:                fireActionEvent();
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.