Source Code Cross Referenced for TemplateRadioButtonDemo.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.swing.layouts.*;
027:
028:        public class TemplateRadioButtonDemo extends JFrame {
029:
030:            public static void main(String[] args) {
031:                new TemplateRadioButtonDemo().setVisible(true);
032:            }
033:
034:            public TemplateRadioButtonDemo() {
035:                setContentPane(new RadioButtonDemoPanel());
036:            }
037:
038:            public JPanel getRadioButtonPanel() {
039:                return new RadioButtonDemoPanel();
040:            }
041:
042:            public static class RadioButtonDemoPanel extends JPanel {
043:
044:                String birdString = "Bird";
045:                String catString = "Cat";
046:                String dogString = "Dog";
047:                String rabbitString = "Rabbit";
048:                String pigString = "Pig";
049:
050:                JLabel picture;
051:
052:                public RadioButtonDemoPanel() {
053:                    // Create the radio buttons.
054:                    final JRadioButton birdButton = new JRadioButton(birdString);
055:                    birdButton.setMnemonic(KeyEvent.VK_B);
056:                    birdButton.setActionCommand(birdString);
057:                    birdButton.setSelected(true);
058:                    birdButton
059:                            .setLayout(new TemplateLayout(
060:                                    WosFramework
061:                                            .getKeyPositionTemplateForName("RadioButtonDemo.twoElements.radioButtonPanel.radio1")));
062:
063:                    final JRadioButton catButton = new JRadioButton(catString);
064:                    catButton.setMnemonic(KeyEvent.VK_C);
065:                    catButton.setActionCommand(catString);
066:                    catButton
067:                            .setLayout(new TemplateLayout(
068:                                    WosFramework
069:                                            .getKeyPositionTemplateForName("RadioButtonDemo.twoElements.radioButtonPanel.radio1")));
070:
071:                    final JRadioButton dogButton = new JRadioButton(dogString);
072:                    dogButton.setMnemonic(KeyEvent.VK_D);
073:                    dogButton.setActionCommand(dogString);
074:                    dogButton
075:                            .setLayout(new TemplateLayout(
076:                                    WosFramework
077:                                            .getKeyPositionTemplateForName("RadioButtonDemo.twoElements.radioButtonPanel.radio1")));
078:                    dogButton.putClientProperty("theUserUniqueName",
079:                            "DogButton");
080:
081:                    final JRadioButton rabbitButton = new JRadioButton(
082:                            rabbitString);
083:                    rabbitButton.setMnemonic(KeyEvent.VK_R);
084:                    rabbitButton.setActionCommand(rabbitString);
085:                    rabbitButton
086:                            .setLayout(new TemplateLayout(
087:                                    WosFramework
088:                                            .getKeyPositionTemplateForName("RadioButtonDemo.twoElements.radioButtonPanel.radio1")));
089:
090:                    final JRadioButton pigButton = new JRadioButton(pigString);
091:                    pigButton.setMnemonic(KeyEvent.VK_P);
092:                    pigButton.setActionCommand(pigString);
093:                    pigButton
094:                            .setLayout(new TemplateLayout(
095:                                    WosFramework
096:                                            .getKeyPositionTemplateForName("RadioButtonDemo.twoElements.radioButtonPanel.radio1")));
097:
098:                    // Group the radio buttons.
099:                    ButtonGroup group = new ButtonGroup();
100:                    group.add(birdButton);
101:                    group.add(catButton);
102:                    group.add(dogButton);
103:                    group.add(rabbitButton);
104:                    group.add(pigButton);
105:
106:                    picture = new JLabel();
107:                    picture.setIcon(new ImageIcon("resources/images/"
108:                            + birdString + ".gif"));
109:
110:                    class RadioListener implements  ActionListener {
111:                        public void actionPerformed(ActionEvent e) {
112:                            picture.setIcon(new ImageIcon("resources/images/"
113:                                    + e.getActionCommand() + ".gif"));
114:                        }
115:
116:                        public String getName() {
117:                            return "ChangePicture";
118:                        }
119:
120:                        public Object[] getParameters() {
121:                            return new Object[] { picture };
122:                        }
123:                    }
124:
125:                    RadioListener myListener = new RadioListener();
126:                    birdButton.addActionListener(myListener);
127:                    catButton.addActionListener(myListener);
128:                    dogButton.addActionListener(myListener);
129:                    rabbitButton.addActionListener(myListener);
130:                    pigButton.addActionListener(myListener);
131:
132:                    // Set up the picture label
133:
134:                    // The preferred size is hard-coded to be the width of the
135:                    // widest image and the height of the tallest image.
136:                    // A real program would compute this.
137:                    picture.setPreferredSize(new Dimension(177, 122));
138:                    picture
139:                            .setLayout(new TemplateLayout(
140:                                    WosFramework
141:                                            .getKeyPositionTemplateForName("RadioButtonDemo.twoElements.thePicture")));
142:
143:                    // Put the radio buttons in a column in a panel
144:                    JPanel radioPanel = new JPanel();
145:                    radioPanel
146:                            .setLayout(new TemplateLayout(
147:                                    WosFramework
148:                                            .getKeyPositionTemplateForName("RadioButtonDemo.twoElements.radioButtonPanel")));
149:
150:                    radioPanel.add(birdButton, "radio1");
151:                    radioPanel.add(catButton, "radio2");
152:                    radioPanel.add(dogButton, "radio3");
153:                    radioPanel.add(rabbitButton, "radio4");
154:                    radioPanel.add(pigButton, "radio5");
155:
156:                    setLayout(new TemplateLayout(
157:                            WosFramework
158:                                    .getKeyPositionTemplateForName("RadioButtonDemo.twoElements")));
159:                    add(radioPanel, "radioButtonPanel");
160:                    add(picture, "thePicture");
161:
162:                    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
163:                }
164:            }
165:
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.