Source Code Cross Referenced for IntegerField.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:        // IntegerField.java
002:        // $Id: IntegerField.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 IntegerFieldEditor extends TextField {
014:            IntegerField field = null;
015:
016:            public boolean action(Event evt, Object arg) {
017:                try {
018:                    Integer ival = new Integer(Integer.parseInt(getText()));
019:                    if (!field.acceptChange(ival))
020:                        setText(field.getValue().toString());
021:                    return true;
022:                } catch (NumberFormatException ex) {
023:                    // This should never happen!
024:                    throw new RuntimeException("implementation bug !");
025:                }
026:            }
027:
028:            public void setValue(Integer ival) {
029:                setText(ival.toString());
030:            }
031:
032:            /**
033:             * Handle event: manage fields walking.
034:             * @param evt The event to handle.
035:             */
036:
037:            public boolean keyDown(Event evt, int key) {
038:                switch (key) {
039:                case 9:
040:                case 10:
041:                    action(evt, evt.arg);
042:                    field.manager.nextField();
043:                    return true;
044:                case '0':
045:                case '1':
046:                case '2':
047:                case '3':
048:                case '4':
049:                case '5':
050:                case '6':
051:                case '7':
052:                case '8':
053:                case '9':
054:                case Event.LEFT:
055:                case Event.RIGHT:
056:                case 96:
057:                case 127:
058:                    return super .keyDown(evt, key);
059:                default:
060:                    // Not allowed here
061:                    return true;
062:                }
063:            }
064:
065:            IntegerFieldEditor(IntegerField field, Integer ival) {
066:                super (ival.toString());
067:                this .field = field;
068:            }
069:        }
070:
071:        /**
072:         * An editor for integer field.
073:         */
074:
075:        public class IntegerField extends FormField {
076:            /**
077:             * Our current value.
078:             */
079:            Integer ival = new Integer(0);
080:            /**
081:             * Our GUI editor.
082:             */
083:            IntegerFieldEditor editor = null;
084:
085:            /**
086:             * Get an editor to edit this form field.
087:             */
088:
089:            public Component getEditor() {
090:                if (editor == null)
091:                    editor = new IntegerFieldEditor(this , ival);
092:                return editor;
093:            }
094:
095:            /**
096:             * Get this field integer value.
097:             * @return The current field's value.
098:             */
099:
100:            public int getIntValue() {
101:                return ival.intValue();
102:            }
103:
104:            /**
105:             * Do we accept this new value as our setting ?
106:             */
107:
108:            public boolean acceptChange(Integer ival) {
109:                try {
110:                    setValue(ival, true, false);
111:                } catch (IllegalFieldValueException ex) {
112:                    throw new RuntimeException("implementation bug.");
113:                }
114:                return true;
115:            }
116:
117:            /**
118:             * Get our value, in its native type.
119:             */
120:
121:            public Object getValue() {
122:                return ival;
123:            }
124:
125:            /**
126:             * Set our value.
127:             * @param value The proposed value.
128:             * @exception IllegalFieldValueException if the value isn't accepted
129:             */
130:
131:            public void setValue(Integer ival, boolean notify, boolean update)
132:                    throws IllegalFieldValueException {
133:                this .ival = ival;
134:                if (update && (editor != null))
135:                    editor.setValue(ival);
136:                if (notify)
137:                    manager.notifyChange(this );
138:            }
139:
140:            /**
141:             * Set our value.
142:             * @param value The proposed value.
143:             * @exception IllegalFieldValueException if the value isn't accepted
144:             */
145:            public void setValue(Object value, boolean notify, boolean update)
146:                    throws IllegalFieldValueException {
147:                if (!(value instanceof  Integer))
148:                    throw new IllegalFieldValueException(value);
149:                setValue((Integer) value, update);
150:            }
151:
152:            public IntegerField(FormManager manager, String name, String title,
153:                    Integer ival) {
154:                super (manager, name, title);
155:                this .ival = ival;
156:            }
157:
158:            public IntegerField(FormManager manager, String name, String title,
159:                    int value) {
160:                this (manager, name, title, new Integer(value));
161:            }
162:
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.