Source Code Cross Referenced for StringField.java in  » Web-Server » Jigsaw » org » w3c » tools » forms » 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 Server » Jigsaw » org.w3c.tools.forms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // StringField.java
002:        // $Id: StringField.java,v 1.4 2000/08/16 21:37:49 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.tools.forms;
007:
008:        import java.awt.Component;
009:        import java.awt.Event;
010:        import java.awt.TextComponent;
011:        import java.awt.TextField;
012:
013:        class StringFieldEditor extends TextField {
014:            StringField field = null;
015:
016:            /**
017:             * Handle the action: the field edition is finished.
018:             */
019:
020:            public boolean action(Event evt, Object arg) {
021:                if (!field.acceptChange(getText())) {
022:                    String oldtxt = field.getStringValue();
023:                    setText((oldtxt != null) ? oldtxt : "");
024:                }
025:                return true;
026:            }
027:
028:            /**
029:             * Set the editor's value.
030:             */
031:
032:            public void setValue(String value) {
033:                setText((value == null) ? "" : value);
034:            }
035:
036:            /**
037:             * This editor got the focus, notify the form manager.
038:             */
039:
040:            public boolean gotFocus(Event evt, Object what) {
041:                field.gotFocus();
042:                return false;
043:            }
044:
045:            /**
046:             * Handle event: manage fields walking.
047:             * @param evt The event to handle.
048:             */
049:
050:            public boolean keyDown(Event evt, int key) {
051:                switch (key) {
052:                case 9:
053:                case 10:
054:                    action(evt, evt.arg);
055:                    field.manager.nextField();
056:                    return true;
057:                default:
058:                    return super .keyDown(evt, key);
059:                }
060:            }
061:
062:            StringFieldEditor(StringField field, String defvalue) {
063:                super ((defvalue == null) ? "" : defvalue, 32);
064:                this .field = field;
065:            }
066:
067:        }
068:
069:        /**
070:         * An editor for string fields.
071:         */
072:
073:        public class StringField extends FormField {
074:            /**
075:             * Our current value.
076:             */
077:            String value = null;
078:            /**
079:             * Our GUI editor.
080:             */
081:            StringFieldEditor editor = null;
082:
083:            /**
084:             * Do we want to accept this value as our new value.
085:             */
086:
087:            public boolean acceptChange(String value) {
088:                try {
089:                    setValue(value, true, false);
090:                } catch (IllegalFieldValueException ex) {
091:                    throw new RuntimeException("implementation bug.");
092:                }
093:                return true;
094:            }
095:
096:            /**
097:             * Get this field's value according to its native type.
098:             */
099:
100:            public Object getValue() {
101:                return value;
102:            }
103:
104:            /**
105:             * Get this field value as a String.
106:             */
107:
108:            public String getStringValue() {
109:                return value;
110:            }
111:
112:            /**
113:             * Set this field value.
114:             * @exception IllegalFieldValueException if the value isn't accepted
115:             */
116:
117:            public void setValue(Object value, boolean notify, boolean update)
118:                    throws IllegalFieldValueException {
119:                if (!(value instanceof  String))
120:                    throw new IllegalFieldValueException(value);
121:                setValue((String) value, notify, update);
122:            }
123:
124:            /**
125:             * Set this field value.
126:             * @exception IllegalFieldValueException if the value isn't accepted
127:             */
128:            public void setValue(String value, boolean notify, boolean update)
129:                    throws IllegalFieldValueException {
130:                this .value = value;
131:                if (update && (editor != null))
132:                    editor.setValue(value);
133:                if (notify)
134:                    manager.notifyChange(this );
135:            }
136:
137:            /**
138:             * FormField implementation - Get the editor for the field.
139:             */
140:
141:            public Component getEditor() {
142:                if (editor == null)
143:                    editor = new StringFieldEditor(this , value);
144:                return editor;
145:            }
146:
147:            /**
148:             * Create a new field for string edition.
149:             * @param manager The form manager.
150:             * @param value The initial value for the field.
151:             */
152:
153:            public StringField(FormManager manager, String name, String title,
154:                    String value) {
155:                super (manager, name, title);
156:                this .value = value;
157:            }
158:
159:            /**
160:             * Create a new field for string edition, with no initial value.
161:             * @param manager The form manager.
162:             * @param name The field's name.
163:             * @param title The field's title.
164:             */
165:
166:            public StringField(FormManager manager, String name, String title) {
167:                this(manager, name, title, null);
168:            }
169:
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.