Source Code Cross Referenced for DoubleField.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:        // DoubleField.java
002:        // $Id: DoubleField.java,v 1.4 2000/08/16 21:37:49 ylafon Exp $  
003:        // (c) COPYRIGHT MIT and INRIA, 1997.
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 DoubleFieldEditor extends TextField {
014:            DoubleField field = null;
015:            boolean donext = false;
016:
017:            public boolean action(Event evt, Object arg) {
018:                try {
019:                    Double dval = Double.valueOf(getText());
020:                    if (field.acceptChange(dval)) {
021:                        donext = true;
022:                        return true;
023:                    }
024:                } catch (NumberFormatException ex) {
025:                }
026:                // The new proposed value was rejected, retreiev the old value:
027:                Double oldval = (Double) field.getValue();
028:                if (oldval != null)
029:                    setText(oldval.toString());
030:                else
031:                    setText("");
032:                return true;
033:            }
034:
035:            /**
036:             * Notify the form manager that we did get the focus.
037:             */
038:
039:            public boolean gotFocus(Event evt, Object what) {
040:                field.gotFocus();
041:                return false;
042:            }
043:
044:            public void setValue(Double dval) {
045:                setText(dval.toString());
046:            }
047:
048:            /**
049:             * Handle event: manage fields walking.
050:             * @param evt The event to handle.
051:             */
052:
053:            public boolean keyDown(Event evt, int key) {
054:                switch (key) {
055:                case 9:
056:                case 10:
057:                    action(evt, evt.arg);
058:                    if (donext) {
059:                        donext = false;
060:                        field.manager.nextField();
061:                    }
062:                    return true;
063:                default:
064:                    return super .keyDown(evt, key);
065:                }
066:            }
067:
068:            DoubleFieldEditor(DoubleField field, Double dval) {
069:                super ((dval != null) ? dval.toString() : "");
070:                this .field = field;
071:            }
072:
073:        }
074:
075:        public class DoubleField extends FormField {
076:            /**
077:             * Our editor for the field value.
078:             */
079:            DoubleFieldEditor editor = null;
080:            /**
081:             * Our current value.
082:             */
083:            Double value = null;
084:
085:            /**
086:             * Do we want to accept this new value ?
087:             * @return A boolean, <strong>true</strong> if we accept this new
088:             *    value.
089:             */
090:
091:            public boolean acceptChange(Double dval) {
092:                try {
093:                    setValue(dval, true, false);
094:                } catch (IllegalFieldValueException ex) {
095:                    throw new RuntimeException("implementation bug.");
096:                }
097:                return true;
098:            }
099:
100:            /**
101:             * Get this field's value in its native format (ie Double).
102:             * @return An instance of Double.
103:             */
104:
105:            public Object getValue() {
106:                return value;
107:            }
108:
109:            /**
110:             * Get this field's value as a Double.
111:             * @return An instance of Double.
112:             */
113:
114:            public Double getDoubleValue() {
115:                return value;
116:            }
117:
118:            /**
119:             * Set this field's value to thegiven object.
120:             * @param value The new value for the field.
121:             * @param update Should the editor updates its view ?
122:             * @exception IllegalFieldValueException If the provided value is not
123:             *    a Double object.
124:             */
125:
126:            public void setValue(Object value, boolean notify, boolean update)
127:                    throws IllegalFieldValueException {
128:                if (!(value instanceof  Double))
129:                    throw new IllegalFieldValueException(value);
130:                setValue((Double) value, notify, update);
131:            }
132:
133:            /**
134:             * Set this field's value to the given Double value.
135:             * @param value The double value to set the field to.
136:             * @param update Should the editor updates its view ?
137:             * @exception IllegalFieldValueException If the value couldn't be set.
138:             */
139:
140:            public void setValue(Double value, boolean notify, boolean update)
141:                    throws IllegalFieldValueException {
142:                this .value = value;
143:                if (update && (editor != null))
144:                    editor.setValue(value);
145:                if (notify)
146:                    manager.notifyChange(this );
147:            }
148:
149:            /**
150:             * Get an editor for this field.
151:             */
152:
153:            public Component getEditor() {
154:                if (editor == null)
155:                    editor = new DoubleFieldEditor(this , value);
156:                return editor;
157:            }
158:
159:            /**
160:             * Create a new double field.
161:             * @param manager The associated form manager.
162:             * @param name The name for this field.
163:             * @param title This field's title.
164:             * @param value The initial value for the field.
165:             * @exception IllegalFieldValueException If the default value isn't 
166:             *    accepted by the field.
167:             */
168:
169:            public DoubleField(FormManager manager, String name, String title,
170:                    Double value) throws IllegalFieldValueException {
171:                super (manager, name, title);
172:                setValue(value, false);
173:            }
174:
175:            /**
176:             * Create a new uninitialized double field.
177:             * @param manager The asociated form manager.
178:             * @param name The field's name.
179:             * @param title The field's title.
180:             */
181:
182:            public DoubleField(FormManager manager, String name, String title) {
183:                super(manager, name, title);
184:                this.value = null;
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.