Source Code Cross Referenced for ToggleButtonExample.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:        /*
002:         * Copyright 2000,2005 wingS development team.
003:         *
004:         * This file is part of wingS (http://wingsframework.org).
005:         *
006:         * wingS is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU Lesser General Public License
008:         * as published by the Free Software Foundation; either version 2.1
009:         * of the License, or (at your option) any later version.
010:         *
011:         * Please see COPYING for the complete licence.
012:         */
013:        package wingset;
014:
015:        import org.wings.*;
016:
017:        import java.awt.event.ActionEvent;
018:        import java.awt.event.ActionListener;
019:        import java.util.Iterator;
020:
021:        /**
022:         * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
023:         */
024:        public class ToggleButtonExample extends WingSetPane {
025:            final static int[] textHPos = new int[] { SConstants.LEFT,
026:                    SConstants.CENTER, SConstants.RIGHT };
027:            final static int[] textVPos = new int[] { SConstants.TOP,
028:                    SConstants.CENTER, SConstants.BOTTOM };
029:
030:            static final SIcon icon = new SURLIcon("../icons/ButtonIcon.gif");
031:            static final SIcon disabledIcon = new SURLIcon(
032:                    "../icons/ButtonDisabledIcon.gif");
033:            static final SIcon pressedIcon = new SURLIcon(
034:                    "../icons/ButtonPressedIcon.gif");
035:            static final SIcon rolloverIcon = new SURLIcon(
036:                    "../icons/ButtonRolloverIcon.gif");
037:            private ButtonControls controls;
038:
039:            private final SLabel reportLabel = new SLabel("No button pressed");
040:            protected ActionListener action = new java.awt.event.ActionListener() {
041:                public void actionPerformed(ActionEvent e) {
042:                    reportLabel.setText("<html>Button <b>'"
043:                            + e.getActionCommand() + "'</b> pressed");
044:                }
045:            };
046:            private SGridLayout grid;
047:            private SPanel gridPanel;
048:
049:            protected SComponent createControls() {
050:                controls = new ButtonControls();
051:                return controls;
052:            }
053:
054:            public SComponent createExample() {
055:                return createButtonExample();
056:            }
057:
058:            SContainer createButtonExample() {
059:                SButtonGroup group = new SButtonGroup();
060:                SToggleButton[] buttons = new SToggleButton[9];
061:
062:                for (int i = 0; i < buttons.length; i++) {
063:                    SToggleButton button = buttons[i] = new SToggleButton(
064:                            "Text " + (i + 1));
065:                    button.setShowAsFormComponent(true);
066:                    button.setActionCommand(button.getText());
067:                    if (i != 4) {
068:                        button.setIcon(icon);
069:                        button.setDisabledIcon(disabledIcon);
070:                        button.setRolloverIcon(rolloverIcon);
071:                        button.setPressedIcon(pressedIcon);
072:                        button.setSelectedIcon(pressedIcon);
073:                    }
074:                    button.setToolTipText("ToggleButton " + (i + 1));
075:                    button.setName("tb" + (i + 1));
076:                    button.setVerticalTextPosition(textVPos[(i / 3) % 3]);
077:                    button.setHorizontalTextPosition(textHPos[i % 3]);
078:                    group.add(button);
079:                    controls.addControllable(button);
080:                }
081:
082:                grid = new SGridLayout(3);
083:                gridPanel = new SPanel(grid);
084:                grid.setHgap(10);
085:                grid.setVgap(10);
086:
087:                for (int i = 0; i < buttons.length; i++) {
088:                    buttons[i].addActionListener(action);
089:                    gridPanel.add(buttons[i]);
090:                }
091:
092:                final SPanel panel = new SPanel(new SGridLayout(2, 1, 0, 20));
093:                panel.add(gridPanel);
094:                panel.add(reportLabel);
095:
096:                return panel;
097:            }
098:
099:            class ButtonControls extends ComponentControls {
100:                public ButtonControls() {
101:                    formComponentCheckBox.setSelected(true);
102:                    formComponentCheckBox
103:                            .addActionListener(new ActionListener() {
104:                                public void actionPerformed(ActionEvent e) {
105:                                    grid.setBorder(formComponentCheckBox
106:                                            .isSelected() ? 0 : 1);
107:                                    gridPanel.reload();
108:                                }
109:                            });
110:
111:                    final SCheckBox useImages = new SCheckBox("Use Icons");
112:                    useImages.setSelected(true);
113:                    useImages
114:                            .addActionListener(new java.awt.event.ActionListener() {
115:                                public void actionPerformed(ActionEvent e) {
116:                                    boolean use = useImages.isSelected();
117:
118:                                    for (Iterator iterator = components
119:                                            .iterator(); iterator.hasNext();) {
120:                                        SAbstractButton component = (SAbstractButton) iterator
121:                                                .next();
122:                                        if (!"tb5".equals(component.getName())) {
123:                                            component
124:                                                    .setIcon(use ? icon : null);
125:                                            component
126:                                                    .setDisabledIcon(use ? disabledIcon
127:                                                            : null);
128:                                            component
129:                                                    .setRolloverIcon(use ? rolloverIcon
130:                                                            : null);
131:                                            component
132:                                                    .setPressedIcon(use ? pressedIcon
133:                                                            : null);
134:                                            component
135:                                                    .setSelectedIcon(use ? pressedIcon
136:                                                            : null);
137:                                        }
138:                                    }
139:                                }
140:                            });
141:                    addControl(useImages);
142:                }
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.