Source Code Cross Referenced for LabelButtonTextDemo.java in  » Web-Framework » swingweb » org » onemind » swingweb » widgetdemo » 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 » swingweb » org.onemind.swingweb.widgetdemo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2004 TiongHiang Lee
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:         * Email: thlee@onemindsoft.org
019:         */
020:
021:        package org.onemind.swingweb.widgetdemo;
022:
023:        import java.awt.*;
024:        import java.awt.event.ActionEvent;
025:        import java.awt.event.ActionListener;
026:        import java.io.InputStream;
027:        import javax.swing.*;
028:        import javax.swing.event.ChangeEvent;
029:        import javax.swing.event.ChangeListener;
030:        import org.onemind.swingweb.component.layout.TableLayout;
031:
032:        public class LabelButtonTextDemo extends AbstractDemo implements 
033:                ActionListener, ChangeListener {
034:
035:            public LabelButtonTextDemo(DemoConsole console) {
036:                super ("Label, Button and Text", console);
037:                setLayout(new FlowLayout());
038:                add(getDemoArea());
039:            }
040:
041:            public Container getDemoArea() {
042:                JPanel pnl = new JPanel();
043:                TableLayout layout = new TableLayout(pnl);
044:                pnl.setLayout(layout);
045:                layout.getConstraint().fill = GridBagConstraints.BOTH;
046:                layout.getConstraint().insets = new Insets(5, 5, 5, 5);
047:                Icon icon = new ImageIcon(getClass().getResource(
048:                        "/org/onemind/swingweb/widgetdemo/icecream.jpg"));
049:
050:                /** labels **/
051:                //just a label
052:                JLabel lbl = new JLabel("This is a yellow JLabel");
053:                lbl.setForeground(Color.YELLOW);
054:                layout.addNextRow(lbl);
055:
056:                //label with colors
057:                lbl = new JLabel(
058:                        "<html>This is a <font color=\"blue\"><i>html</i></font> JLabel</html>");
059:                layout.addNextRow(lbl);
060:
061:                //label with icon
062:                lbl = new JLabel("JLabel with icon");
063:                lbl.setIcon(icon);
064:                layout.addNextRow(lbl);
065:
066:                //disabled label 
067:                lbl = new JLabel("Disabled JLabel");
068:                layout.addNextRow(lbl);
069:
070:                /** buttons **/
071:                //button
072:                JButton btn = new JButton("Button1");
073:                btn.setBackground(Color.YELLOW);
074:                layout.addNextRow(btn);
075:                layout.addNextCell(new JLabel(
076:                        "Just a JButton with yellow background"));
077:
078:                //button with listener
079:                btn = new JButton("Button2");
080:                btn.addActionListener(this );
081:                layout.addNextRow(btn);
082:                layout.addNextCell(new JLabel(
083:                        "JButton with listener. Push will submit"));
084:
085:                //button with no border
086:                btn = new JButton("Button3");
087:                btn.setBorder(null);
088:                layout.addNextRow(btn);
089:                layout.addNextCell(new JLabel("JButton with no border"));
090:
091:                //button with icon
092:                btn = new JButton("Button4");
093:                btn.setIcon(icon);
094:                layout.addNextRow(btn);
095:                layout.addNextCell(new JLabel("JButton with icon"));
096:
097:                /** checkboxes **/
098:                //button
099:                JCheckBox checkbox = new JCheckBox("Checkbox1");
100:                checkbox.setBackground(Color.YELLOW);
101:                layout.addNextRow(checkbox);
102:                layout.addNextCell(new JLabel(
103:                        "Just a JCheckbox with yellow background"));
104:
105:                //button with listener
106:                checkbox = new JCheckBox("Checkbox2");
107:                checkbox.addChangeListener(this );
108:                layout.addNextRow(checkbox);
109:                layout.addNextCell(new JLabel(
110:                        "JCheckBox with change listener. Push will submit"));
111:
112:                //button in a group
113:                JPanel subPanel = new JPanel();
114:                subPanel.setLayout(new GridLayout(1, 2));
115:                ButtonGroup group = new ButtonGroup();
116:                checkbox = new JCheckBox("Checkbox3");
117:                group.add(checkbox);
118:                subPanel.add(checkbox);
119:                checkbox = new JCheckBox("Checkbox4");
120:                group.add(checkbox);
121:                subPanel.add(checkbox);
122:                layout.addNextRow(subPanel);
123:                layout.addNextCell(new JLabel(
124:                        "JCheckBox in button group. Push always submit"));
125:
126:                /** radio buttons **/
127:                //      button in a group
128:                subPanel = new JPanel();
129:                subPanel.setLayout(new GridLayout(1, 2));
130:                group = new ButtonGroup();
131:                JRadioButton rbtn = new JRadioButton("RadioButton1");
132:                group.add(rbtn);
133:                subPanel.add(rbtn);
134:                rbtn = new JRadioButton("RadioButton2");
135:                group.add(rbtn);
136:                subPanel.add(rbtn);
137:                layout.addNextRow(subPanel);
138:                layout.addNextCell(new JLabel("RadioButtons in button group"));
139:
140:                //button in a group with listener
141:                subPanel = new JPanel();
142:                subPanel.setLayout(new GridLayout(1, 2));
143:                group = new ButtonGroup();
144:                rbtn = new JRadioButton("RadioButton1");
145:                group.add(rbtn);
146:                rbtn.addChangeListener(this );
147:                subPanel.add(rbtn);
148:                rbtn = new JRadioButton("RadioButton2");
149:                group.add(rbtn);
150:                rbtn.addActionListener(this );
151:                subPanel.add(rbtn);
152:                layout.addNextRow(subPanel);
153:                layout
154:                        .addNextCell(new JLabel(
155:                                "RadioButtons with change/action listener in button group. Push will submit"));
156:
157:                /** text demo **/
158:                //Text field
159:                JTextField fld = new JTextField();
160:                fld.setColumns(10);
161:                fld.setText("Test");
162:                layout.addNextRow(fld);
163:                layout.addNextCell(new JLabel("Just a text field"));
164:
165:                //Text field with TextListner
166:                fld = new JTextField();
167:                fld.setColumns(10);
168:                fld.setText("Test");
169:                layout.addNextRow(fld);
170:                layout.addNextCell(new JLabel("Texd field with text listener"));
171:
172:                //Password field
173:                fld = new JPasswordField();
174:                fld.setColumns(10);
175:                layout.addNextRow(fld);
176:                layout.addNextCell(new JLabel("A password field"));
177:
178:                //Text area
179:                JTextArea tfld = new JTextArea();
180:                tfld.setColumns(10);
181:                tfld.setRows(4);
182:                layout.addNextRow(tfld);
183:                layout.addNextCell(new JLabel("A text area"));
184:                return pnl;
185:            }
186:
187:            public void actionPerformed(ActionEvent e) {
188:                getConsole().log(e.toString());
189:            }
190:
191:            public void stateChanged(ChangeEvent e) {
192:                getConsole().log(e.toString());
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.