Source Code Cross Referenced for XCalendarExample.java in  » Swing-Library » wings3 » wingset » 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 » wingset 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package wingset;
002:
003:        import java.awt.event.ActionEvent;
004:        import java.awt.event.ActionListener;
005:        import java.text.DateFormat;
006:        import java.text.ParseException;
007:        import java.text.ParsePosition;
008:        import java.text.SimpleDateFormat;
009:        import java.util.Calendar;
010:        import java.util.Date;
011:        import java.util.GregorianCalendar;
012:
013:        import javax.swing.*;
014:
015:        import org.wings.*;
016:        import org.wings.text.SDateFormatter;
017:        import org.wingx.XCalendar;
018:
019:        public class XCalendarExample extends WingSetPane {
020:
021:            protected SComponent createControls() {
022:                return null;
023:            }
024:
025:            public SComponent createExample() {
026:                SGridLayout layout = new SGridLayout(3);
027:                layout.setHgap(15);
028:                SPanel panel = new SPanel(layout);
029:
030:                //
031:                // Regular nullable calendar
032:                final DateFormat nullableDateFormat = new NullableDateFormatter();
033:                panel.add(new SLabel("Calendar: ", SConstants.RIGHT_ALIGN));
034:                final XCalendar nullablXCalendar = new XCalendar(
035:                        new SDateFormatter(nullableDateFormat));
036:                nullablXCalendar.setNullable(true);
037:                nullablXCalendar.setDate(null);
038:                panel.add(nullablXCalendar);
039:
040:                final SLabel valueLabel1 = new SLabel("< press submit >");
041:                panel.add(valueLabel1);
042:
043:                //
044:                // Date spinner example
045:                Calendar calendar = new GregorianCalendar();
046:                Date initDate = calendar.getTime();
047:
048:                calendar.add(Calendar.YEAR, -50);
049:                Date earliestDate = calendar.getTime();
050:
051:                calendar.add(Calendar.YEAR, 100);
052:                Date latestDate = calendar.getTime();
053:
054:                final SSpinner spinner = new SSpinner(new SpinnerDateModel(
055:                        initDate, earliestDate, latestDate, Calendar.MONTH));
056:                final CalendarEditor calendarEditor = new CalendarEditor(
057:                        spinner, new SDateFormatter(DateFormat
058:                                .getDateInstance()));
059:                spinner.setEditor(calendarEditor);
060:
061:                panel.add(new SLabel("Spinner: ", SConstants.RIGHT_ALIGN));
062:                panel.add(spinner);
063:
064:                final SLabel valueLabel2 = new SLabel("< press submit >");
065:                panel.add(valueLabel2);
066:
067:                // For debugging purposes. Maybe ommit those labels
068:                final SButton button = new SButton("submit input");
069:                button.addActionListener(new ActionListener() {
070:                    public void actionPerformed(ActionEvent e) {
071:                        valueLabel1.setText("" + nullablXCalendar.getDate());
072:                        valueLabel2.setText(""
073:                                + calendarEditor.getCalendar().getDate());
074:                    }
075:                });
076:                panel.add(new SLabel());
077:                panel.add(button);
078:
079:                return panel;
080:
081:            }
082:
083:            public static class CalendarEditor extends SSpinner.DefaultEditor {
084:                private XCalendar calendar = null;
085:
086:                public CalendarEditor(SSpinner spinner, SDateFormatter formatter) {
087:                    super (spinner);
088:
089:                    removeAll();
090:
091:                    calendar = new XCalendar(formatter);
092:                    calendar.getFormattedTextField().setColumns(15);
093:
094:                    add(calendar);
095:
096:                }
097:
098:                public XCalendar getCalendar() {
099:                    return calendar;
100:                }
101:
102:                public SFormattedTextField getTextField() {
103:                    return calendar.getFormattedTextField();
104:                }
105:            }
106:
107:            /**
108:             * A simple date formatter that parses and allows empty strings as <code>null</code>.
109:             */
110:            private static class NullableDateFormatter extends SimpleDateFormat {
111:                public NullableDateFormatter() {
112:                    super ("dd.MM.yyyy");
113:                }
114:
115:                public Object parseObject(String source) throws ParseException {
116:                    if (source == null || source.trim().length() == 0) {
117:                        return null;
118:                    }
119:                    return super .parseObject(source);
120:                }
121:
122:                public Date parse(String text, ParsePosition pos) {
123:                    if (text == null || text.trim().length() == 0) {
124:                        return null;
125:                    }
126:                    return super.parse(text, pos);
127:                }
128:            }
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.