Source Code Cross Referenced for DemoFunds.java in  » Swing-Library » Swinglets » com » javelin » examples » swinglets » 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 » Swinglets » com.javelin.examples.swinglets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Javelin Software, All rights reserved.
003:         */
004:
005:        package com.javelin.examples.swinglets;
006:
007:        import java.util.*;
008:        import java.io.*;
009:        import java.awt.*;
010:        import java.awt.event.*;
011:
012:        import javax.servlet.*;
013:        import javax.servlet.http.*;
014:
015:        import com.javelin.swinglets.*;
016:        import com.javelin.swinglets.table.*;
017:        import com.javelin.swinglets.border.*;
018:
019:        import javax.swing.*;
020:
021:        import com.javelin.swinglets.event.*;
022:
023:        /** 
024:         * Form Panel for changing funds.
025:         * 
026:         * @author Robin Sharp
027:         */
028:
029:        public class DemoFunds extends SForm implements  FormListener {
030:            public DemoFunds() {
031:                setMethod(SForm.POST);
032:
033:                //BODY TABLE
034:                setLayoutManager(new SGridLayout(6, 1));
035:
036:                SLabel headerLabel1 = new SLabel(
037:                        "Instruction to change investment funds");
038:
039:                headerLabel1.setLink(new SLink()).addActionListener(
040:                        new ActionListener() {
041:                            public void actionPerformed(ActionEvent event) {
042:                                System.out.println("Instructions");
043:                            }
044:                        });
045:
046:                SMatteBorder mb = new SMatteBorder(2, 2, 2, 1, SColor
047:                        .getColor("seagreen4"));
048:                headerLabel1.setBorder(mb);
049:
050:                headerLabel1.setFont("SansSerif", SFont.PLAIN, 24);
051:                headerLabel1.setForeground(blue);
052:                headerLabel1.setHorizontalAlignment(SConstants.CENTER);
053:                headerLabel1.setSize(300, 0);
054:
055:                SLabel headerLabel2 = new SLabel(
056:                        "These instructions to changes investment funds will "
057:                                + "take effect from 4:00pm GMT. ");
058:
059:                headerLabel2.setFont("SansSerif", SFont.PLAIN, 12);
060:                headerLabel2.setForeground(green);
061:                headerLabel2.setHorizontalAlignment(SConstants.CENTER);
062:                headerLabel2.setSize(100, 0);
063:
064:                //FORM TABLE
065:                STable formTable = new STable(3, 4);
066:                formTable.setGridWidth(0);
067:                formTable.setValueAt(new SLabel("Title").setForeground(blue),
068:                        0, 0);
069:                titleField.setToolTipText("Please select your title");
070:                titleField.addItem("Mr");
071:                titleField.addItem("Mrs");
072:                titleField.addItem("Miss");
073:                titleField.addItem("Ms");
074:                formTable.setValueAt(titleField, 0, 1);
075:
076:                formTable.setValueAt(new SLabel("Surname").setForeground(blue),
077:                        0, 2);
078:                formTable.setValueAt(surnameField, 0, 3);
079:
080:                formTable.setValueAt(
081:                        new SLabel("Forename").setForeground(blue), 1, 0);
082:                formTable.setValueAt(forenameField, 1, 1);
083:                formTable.setValueAt(new SCheckBox("Life Style."), 1, 2);
084:                formTable.setValueAt(membershipField.setToolTipText(
085:                        "Member Number").setToolTipText(
086:                        "This is a member number"), 1, 3);
087:
088:                formTable.setValueAt(new SLabel(
089:                        "Enter the fund percentages to a total of 100%.")
090:                        .setFont("Arial,Helvetica", SFont.BOLD, 14)
091:                        .setForeground(SColor.black), 2, 0);
092:                formTable.setCellSpanAt(new Dimension(2, 1), 2, 0);
093:                formTable.setHorizontalAlignmentAt(SConstants.CENTER, 2, 0);
094:
095:                //FUNDS
096:                STable fundsTable = new STable(fundNames.length / 2, 6);
097:
098:                SBorder[] borders = new SBorder[] { new SBevelBorder(2, true),
099:                        new SEmptyBorder(), new SBevelBorder(),
100:                        new SEmptyBorder() };
101:                fundsTable.setBorder(new SCompoundBorder(borders));
102:                fundsTable.setGridWidth(0);
103:                for (int fund = 0, row = 0; fund < fundNames.length; fund += 2, row++) {
104:                    fundsTable.setValueAt(new SLabel(fundNames[fund])
105:                            .setForeground(green), row, 0);
106:                    fundsTable.setValueAt(funds[fund] = new STextField()
107:                            .setColumns(3).setMaxLength(4), row, 1);
108:                    fundsTable.setValueAt("%", row, 2);
109:                    fundsTable.setValueAt(new SLabel(fundNames[fund + 1])
110:                            .setForeground(green), row, 3);
111:                    fundsTable.setValueAt(funds[fund + 1] = new STextField()
112:                            .setColumns(3).setMaxLength(4), row, 4);
113:                    fundsTable.setValueAt("%", row, 5);
114:                }
115:
116:                STable buttonTable = (STable) new STable(2, 2).setGridWidth(0)
117:                        .setSize(300, 35);
118:                buttonTable.setValueAt(totalLabel, 0, 0);
119:                buttonTable.setValueAt(totalAmount, 0, 1);
120:
121:                cancelButton = (SButton) new SButton("CANCEL")
122:                        .setToolTipText("Click here to cancel");
123:                okButton = (SButton) new SButton("OK")
124:                        .setToolTipText("Click here to submit");
125:
126:                buttonTable.setValueAt(cancelButton, 1, 0);
127:                buttonTable.setValueAt(okButton, 1, 1);
128:
129:                add(headerLabel1);
130:                add(headerLabel2);
131:                add(new SCharacter(SCharacter.PARAGRAPH));
132:                add(formTable);
133:                add(fundsTable);
134:                add(buttonTable);
135:
136:                addFormEventListener(this );
137:
138:            }
139:
140:            public void formSubmitted(FormEvent formEvent) {
141:                if (formEvent.getParameter(okButton.getName()) != null) {
142:                    int total = 0;
143:                    int value = 0;
144:                    for (int index = 0; index < fundNames.length; index++) {
145:                        if (funds[index].getText() != null
146:                                && funds[index].getText().length() > 0) {
147:                            try {
148:                                total += Integer.parseInt(funds[index]
149:                                        .getText());
150:                                fundValues[index] = funds[index].getText();
151:                            } catch (Exception e) {
152:                                funds[index].setText(null);
153:                                fundValues[index] = null;
154:                            }
155:                        }
156:                    }
157:
158:                    totalAmount.setText("" + total + "%");
159:
160:                    if (total == 100) {
161:                        totalLabel.setForeground(SColor.black);
162:                        totalLabel.setText("TOTAL ");
163:                    } else if (total < 100) {
164:                        totalLabel.setForeground(red);
165:                        totalLabel.setText("TOTAL TOO LOW ");
166:                    } else if (total > 100) {
167:                        totalLabel.setForeground(red);
168:                        totalLabel.setText("TOTAL TOO HIGH ");
169:                    }
170:
171:                } else if (formEvent.getParameter(cancelButton.getName()) != null) {
172:                    for (int index = 0; index < fundNames.length; index++) {
173:                        funds[index].setText(fundValues[index]);
174:                    }
175:                }
176:
177:            }
178:
179:            private static SColor blue = new SColor(0, 0, 100);
180:            private static SColor green = new SColor(0, 100, 0);
181:            private static SColor red = new SColor(100, 0, 0);
182:
183:            private SComboBox titleField = new SComboBox();
184:            private STextField surnameField = new STextField();
185:            private STextField forenameField = new STextField();
186:            private STextField membershipField = new STextField();
187:
188:            private SButton cancelButton;
189:            private SButton okButton;
190:
191:            private String[] fundNames = new String[] { "Tracker", "Far East",
192:                    "Managed", "European", "Stock Exchange", "Fixed interest",
193:                    "International", "Property", "Equity", "Cash",
194:                    "North American", "Inflation" };
195:
196:            private STextField funds[] = new STextField[fundNames.length];
197:            private String[] fundValues = new String[fundNames.length];
198:
199:            private SLabel totalLabel = (SLabel) new SLabel("TOTAL ").setFont(
200:                    "Arial,Helvetica", SFont.BOLD, 14);
201:            private SLabel totalAmount = (SLabel) new SLabel().setFont(
202:                    "Arial,Helvetica", SFont.BOLD, 14);
203:
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.