Source Code Cross Referenced for TemplateCheckBoxDemo.java in  » Web-Framework » webonswing » examples » withtemplate » 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 Framework » webonswing » examples.withtemplate 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //WebOnSwing - Web Application Framework
002:        //Copyright (C) 2003 Fernando Damian Petrola
003:        //	
004:        //This library is free software; you can redistribute it and/or
005:        //modify it under the terms of the GNU Lesser General Public
006:        //License as published by the Free Software Foundation; either
007:        //version 2.1 of the License, or (at your option) any later version.
008:        //	
009:        //This library is distributed in the hope that it will be useful,
010:        //but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:        //Lesser General Public License for more details.
013:        //	
014:        //You should have received a copy of the GNU Lesser General Public
015:        //License along with this library; if not, write to the Free Software
016:        //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:
018:        package examples.withtemplate;
019:
020:        import java.awt.*;
021:        import java.awt.event.*;
022:
023:        import javax.swing.*;
024:
025:        import net.ar.webonswing.*;
026:        import net.ar.webonswing.remote.*;
027:        import net.ar.webonswing.swing.layouts.*;
028:
029:        public class TemplateCheckBoxDemo extends JDialog {
030:            public static void main(String[] args) {
031:                WosFramework.getInstance().init();
032:                new TemplateCheckBoxDemo().setVisible(true);
033:            }
034:
035:            public TemplateCheckBoxDemo(Frame owner, boolean modal) {
036:                super (owner, modal);
037:                init();
038:            }
039:
040:            public TemplateCheckBoxDemo() {
041:                init();
042:            }
043:
044:            private void init() {
045:                setBounds(0, 0, 400, 400);
046:
047:                addWindowListener(new WindowAdapter() {
048:                    public void windowClosing(WindowEvent e) {
049:                        System.exit(0);
050:                    }
051:                });
052:
053:                setContentPane(getCheckBoxDemoPabel());
054:            }
055:
056:            public JPanel getCheckBoxDemoPabel() {
057:                return new CheckBoxDemoPanel();
058:            }
059:
060:            public static class CheckBoxDemoPanel extends JPanel {
061:                JCheckBox chinButton;
062:                JCheckBox glassesButton;
063:                JCheckBox hairButton;
064:                JCheckBox teethButton;
065:
066:                /*
067:                 * Four accessory choices provide for 16 different
068:                 * combinations. The image for each combination is
069:                 * contained in a separate image file whose name indicates
070:                 * the accessories. The filenames are "geek-XXXX.gif"
071:                 * where XXXX can be one of the following 16 choices.
072:                 * The "choices" StringBuffer contains the string that
073:                 * indicates the current selection and is used to generate
074:                 * the file name of the image to display.
075:                  
076:                	 ----             // zero accessories
077:                  
078:                	 c---             // one accessory
079:                	 -g--
080:                	 --h-
081:                	 ---t
082:                  
083:                	 cg--             // two accessories
084:                	 c-h-
085:                	 c--t
086:                	 -gh-
087:                	 -g-t
088:                	 --ht
089:                  
090:                	 -ght             // three accessories
091:                	 c-ht
092:                	 cg-t
093:                	 cgh-
094:                  
095:                	 cght             // all accessories
096:                 */
097:
098:                StringBuffer choices;
099:                JLabel pictureLabel;
100:
101:                public CheckBoxDemoPanel() {
102:
103:                    // Create the check boxes
104:                    chinButton = new JCheckBox("Chin");
105:                    chinButton.setMnemonic(KeyEvent.VK_C);
106:                    chinButton.setSelected(true);
107:                    chinButton
108:                            .setLayout(new TemplateLayout(
109:                                    WosFramework
110:                                            .getKeyPositionTemplateForName("CheckBoxDemo.twoElements.checkBoxPanel.check1")));
111:
112:                    glassesButton = new JCheckBox("Glasses");
113:                    glassesButton.setMnemonic(KeyEvent.VK_G);
114:                    glassesButton.setSelected(true);
115:                    glassesButton
116:                            .setLayout(new TemplateLayout(
117:                                    WosFramework
118:                                            .getKeyPositionTemplateForName("CheckBoxDemo.twoElements.checkBoxPanel.check1")));
119:
120:                    hairButton = new JCheckBox("Hair");
121:                    hairButton.setMnemonic(KeyEvent.VK_H);
122:                    hairButton.setSelected(true);
123:                    hairButton
124:                            .setLayout(new TemplateLayout(
125:                                    WosFramework
126:                                            .getKeyPositionTemplateForName("CheckBoxDemo.twoElements.checkBoxPanel.check1")));
127:
128:                    teethButton = new JCheckBox("Teeth");
129:                    teethButton.setMnemonic(KeyEvent.VK_T);
130:                    teethButton.setSelected(true);
131:                    teethButton
132:                            .setLayout(new TemplateLayout(
133:                                    WosFramework
134:                                            .getKeyPositionTemplateForName("CheckBoxDemo.twoElements.checkBoxPanel.check1")));
135:
136:                    // Register a listener for the check boxes.
137:                    CheckBoxListener myListener = new CheckBoxListener();
138:                    chinButton.addItemListener(myListener);
139:                    glassesButton.addItemListener(myListener);
140:                    hairButton.addItemListener(myListener);
141:                    teethButton.addItemListener(new CheckBoxListener());
142:
143:                    // Indicates what's on the geek.
144:                    choices = new StringBuffer("cght");
145:
146:                    // Set up the picture label
147:                    pictureLabel = new JLabel();
148:                    pictureLabel.setIcon(new ImageIcon(
149:                            "resources/images/geek/geek-" + choices.toString()
150:                                    + ".gif"));
151:                    pictureLabel.setToolTipText(choices.toString());
152:                    pictureLabel.setText(choices.toString());
153:                    pictureLabel
154:                            .setLayout(new TemplateLayout(
155:                                    WosFramework
156:                                            .getKeyPositionTemplateForName("CheckBoxDemo.twoElements.thePicture")));
157:
158:                    // Put the check boxes in a column in a panel
159:                    JPanel checkPanel = new JPanel();
160:                    checkPanel
161:                            .setLayout(new TemplateLayout(
162:                                    WosFramework
163:                                            .getKeyPositionTemplateForName("CheckBoxDemo.twoElements.checkBoxPanel")));
164:                    checkPanel.add(chinButton, "check1");
165:                    checkPanel.add(glassesButton, "check2");
166:                    checkPanel.add(hairButton, "check3");
167:                    checkPanel.add(teethButton, "check4");
168:
169:                    setLayout(new TemplateLayout(
170:                            WosFramework
171:                                    .getKeyPositionTemplateForName("CheckBoxDemo.twoElements")));
172:
173:                    add(checkPanel, "checkBoxPanel");
174:                    add(pictureLabel, "thePicture");
175:
176:                    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
177:                }
178:
179:                /** Listens to the check boxes. */
180:                class CheckBoxListener implements  ItemListener, RemoteListener {
181:                    public void itemStateChanged(ItemEvent e) {
182:                        int index = 0;
183:                        char c = '-';
184:                        Object source = e.getItemSelectable();
185:
186:                        if (source == chinButton) {
187:                            index = 0;
188:                            c = 'c';
189:                        } else if (source == glassesButton) {
190:                            index = 1;
191:                            c = 'g';
192:                        } else if (source == hairButton) {
193:                            index = 2;
194:                            c = 'h';
195:                        } else if (source == teethButton) {
196:                            index = 3;
197:                            c = 't';
198:                        }
199:
200:                        if (e.getStateChange() == ItemEvent.DESELECTED)
201:                            c = '-';
202:
203:                        choices.setCharAt(index, c);
204:                        pictureLabel.setIcon(new ImageIcon(
205:                                "resources/images/geek/geek-"
206:                                        + choices.toString() + ".gif"));
207:                        pictureLabel.setToolTipText(choices.toString());
208:                        pictureLabel.setText(choices.toString());
209:                    }
210:
211:                    public String getRemoteName() {
212:                        return "CheckBoxListener";
213:                    }
214:
215:                    public Object[] getRemoteParameters() {
216:                        return new Object[] { pictureLabel };
217:                    }
218:                }
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.