Source Code Cross Referenced for ScrollPanel.java in  » Swing-Library » substance-look-feel » test » check » 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 » substance look feel » test.check 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         * 
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer. 
009:         *     
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution. 
013:         *     
014:         *  o Neither the name of Substance Kirill Grouchnikov nor the names of 
015:         *    its contributors may be used to endorse or promote products derived 
016:         *    from this software without specific prior written permission. 
017:         *     
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029:         */
030:        package test.check;
031:
032:        import java.awt.*;
033:        import java.awt.event.ActionEvent;
034:        import java.awt.event.ActionListener;
035:
036:        import javax.swing.*;
037:        import javax.swing.border.LineBorder;
038:
039:        import org.jvnet.lafwidget.LafWidget;
040:        import org.jvnet.lafwidget.preview.DefaultPreviewPainter;
041:        import org.jvnet.substance.SubstanceLookAndFeel;
042:        import org.jvnet.substance.grip.*;
043:        import org.jvnet.substance.theme.SubstanceBottleGreenTheme;
044:        import org.jvnet.substance.utils.SubstanceConstants.ScrollPaneButtonPolicyKind;
045:
046:        import test.Check;
047:
048:        import com.jgoodies.forms.builder.DefaultFormBuilder;
049:        import com.jgoodies.forms.layout.FormLayout;
050:
051:        /**
052:         * Test application panel for testing {@link JScrollPane} component.
053:         * 
054:         * @author Kirill Grouchnikov
055:         */
056:        public class ScrollPanel extends ControllablePanel {
057:            /**
058:             * Scroll panel.
059:             */
060:            private JScrollPane sp;
061:
062:            /**
063:             * The inner panel.
064:             */
065:            private JPanel panel;
066:
067:            /**
068:             * Creates the scroll panel for the test application.
069:             */
070:            public ScrollPanel() {
071:                this .panel = new CheckeredPanel();
072:                this .sp = new JScrollPane(this .panel,
073:                        ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
074:                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
075:                this .setLayout(new BorderLayout());
076:                this .add(this .sp, BorderLayout.CENTER);
077:
078:                FormLayout lm = new FormLayout(
079:                        "right:pref, 4dlu, fill:pref:grow", "");
080:                DefaultFormBuilder builder = new DefaultFormBuilder(lm,
081:                        new ScrollablePanel());
082:
083:                builder.appendSeparator("General settings");
084:                final JCheckBox isEnabled = new JCheckBox("is enabled");
085:                isEnabled.setSelected(true);
086:                isEnabled.addActionListener(new ActionListener() {
087:                    public void actionPerformed(ActionEvent e) {
088:                        boolean toEnable = isEnabled.isSelected();
089:                        sp.setEnabled(toEnable);
090:                        updateEnabledState(sp, toEnable);
091:                        Check.out("Scroll pane is " + toEnable);
092:                    }
093:                });
094:                builder.append("Enabled", isEnabled);
095:
096:                final JCheckBox hasNullBorder = new JCheckBox("Has null border");
097:                hasNullBorder.setSelected(false);
098:                hasNullBorder.addActionListener(new ActionListener() {
099:                    public void actionPerformed(ActionEvent e) {
100:                        if (hasNullBorder.isSelected())
101:                            sp.setBorder(null);
102:                        else
103:                            sp.setBorder(new LineBorder(Color.red));
104:                        sp.repaint();
105:                    }
106:                });
107:                builder.append("Border", hasNullBorder);
108:
109:                builder.appendSeparator("Scrollbar settings");
110:                final JCheckBox useCurrentTheme = new JCheckBox("Use global");
111:                useCurrentTheme.setSelected(true);
112:                useCurrentTheme.addActionListener(new ActionListener() {
113:                    public void actionPerformed(ActionEvent e) {
114:                        sp.getHorizontalScrollBar().putClientProperty(
115:                                SubstanceLookAndFeel.THEME_PROPERTY,
116:                                (useCurrentTheme.isSelected() ? null
117:                                        : new SubstanceBottleGreenTheme()));
118:                        sp.getVerticalScrollBar().putClientProperty(
119:                                SubstanceLookAndFeel.THEME_PROPERTY,
120:                                (useCurrentTheme.isSelected() ? null
121:                                        : new SubstanceBottleGreenTheme()));
122:                        sp.repaint();
123:                    }
124:                });
125:                builder.append("Theme", useCurrentTheme);
126:
127:                final JCheckBox isOverlay = new JCheckBox("Has overlay");
128:                isOverlay.addActionListener(new ActionListener() {
129:                    public void actionPerformed(ActionEvent e) {
130:                        sp.putClientProperty(
131:                                SubstanceLookAndFeel.OVERLAY_PROPERTY,
132:                                isOverlay.isSelected() ? Boolean.TRUE : null);
133:                        sp.repaint();
134:                    }
135:                });
136:                builder.append("Overlay", isOverlay);
137:
138:                builder.append("Composite", new BackgroundCompositeCombo(sp));
139:
140:                final JCheckBox isNotActive = new JCheckBox(
141:                        "is not painted active");
142:                isNotActive.addActionListener(new ActionListener() {
143:                    public void actionPerformed(ActionEvent e) {
144:                        sp
145:                                .putClientProperty(
146:                                        SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY,
147:                                        isNotActive.isSelected() ? Boolean.FALSE
148:                                                : null);
149:                        sp.repaint();
150:                    }
151:                });
152:                builder.append("Active state", isNotActive);
153:
154:                final JCheckBox hasPreview = new JCheckBox("Has preview");
155:                hasPreview.addActionListener(new ActionListener() {
156:                    public void actionPerformed(ActionEvent e) {
157:                        sp
158:                                .putClientProperty(
159:                                        LafWidget.COMPONENT_PREVIEW_PAINTER,
160:                                        hasPreview.isSelected() ? new DefaultPreviewPainter()
161:                                                : null);
162:                    }
163:                });
164:                builder.append("Preview", hasPreview);
165:
166:                builder.appendSeparator("Grip painters");
167:                ButtonGroup gripGroup = new ButtonGroup();
168:                JRadioButton defaultGrip = getGripControl(sp, null,
169:                        "Default (no)", true, gripGroup);
170:                JRadioButton bumpsGrip = getGripControl(sp,
171:                        new DragBumpsGripPainter(), "Drag bumps", false,
172:                        gripGroup);
173:                JRadioButton nullGrip = getGripControl(sp,
174:                        new NullGripPainter(), "Null", false, gripGroup);
175:                builder.append("Select", defaultGrip);
176:                builder.append("", bumpsGrip);
177:                builder.append("", nullGrip);
178:                // final JCheckBox hasCustomGripPainter = new JCheckBox("Has grip
179:                // painter");
180:                // hasCustomGripPainter.addActionListener(new ActionListener() {
181:                // public void actionPerformed(ActionEvent e) {
182:                // sp
183:                // .putClientProperty(
184:                // SubstanceLookAndFeel.GRIP_PAINTER,
185:                // hasCustomGripPainter.isSelected() ? new
186:                // CoreGripPainters.DragBumpsGripPainter()
187:                // : null);
188:                // sp.repaint();
189:                // }
190:                // });
191:                // builder.append("Grips", hasCustomGripPainter);
192:
193:                builder.appendSeparator("Scroll buttons settings");
194:                final JComboBox buttonPolicyCombo = new JComboBox(new Object[] {
195:                        ScrollPaneButtonPolicyKind.NONE,
196:                        ScrollPaneButtonPolicyKind.OPPOSITE,
197:                        ScrollPaneButtonPolicyKind.ADJACENT,
198:                        ScrollPaneButtonPolicyKind.MULTIPLE,
199:                        ScrollPaneButtonPolicyKind.MULTIPLE_BOTH });
200:                buttonPolicyCombo
201:                        .setSelectedItem(ScrollPaneButtonPolicyKind.OPPOSITE);
202:                buttonPolicyCombo.addActionListener(new ActionListener() {
203:                    public void actionPerformed(ActionEvent e) {
204:                        ScrollPaneButtonPolicyKind buttonPolicy = (ScrollPaneButtonPolicyKind) buttonPolicyCombo
205:                                .getSelectedItem();
206:                        sp
207:                                .putClientProperty(
208:                                        SubstanceLookAndFeel.SCROLL_PANE_BUTTONS_POLICY,
209:                                        buttonPolicy);
210:                        sp.repaint();
211:                    }
212:                });
213:                builder.append("Button policy", buttonPolicyCombo);
214:
215:                final JCheckBox isFlat = new JCheckBox("Is flat");
216:                isFlat.addActionListener(new ActionListener() {
217:                    public void actionPerformed(ActionEvent e) {
218:                        sp.putClientProperty(
219:                                SubstanceLookAndFeel.FLAT_PROPERTY, isFlat
220:                                        .isSelected() ? Boolean.TRUE : null);
221:                        sp.repaint();
222:                    }
223:                });
224:                builder.append("Flat", isFlat);
225:
226:                final JCheckBox isNever = new JCheckBox("Is never painted");
227:                isNever.addActionListener(new ActionListener() {
228:                    public void actionPerformed(ActionEvent e) {
229:                        sp
230:                                .putClientProperty(
231:                                        SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY,
232:                                        isNever.isSelected() ? Boolean.TRUE
233:                                                : null);
234:                        sp.repaint();
235:                    }
236:                });
237:                builder.append("Never", isNever);
238:
239:                this .controlPanel = builder.getPanel();
240:            }
241:
242:            private JRadioButton getGripControl(final JScrollPane scrollPane,
243:                    final GripPainter gripPainter, String text,
244:                    boolean isDefault, ButtonGroup buttonGroup) {
245:                final JRadioButton result = new JRadioButton(text);
246:                result.setSelected(isDefault);
247:                buttonGroup.add(result);
248:                result.addActionListener(new ActionListener() {
249:                    public void actionPerformed(ActionEvent e) {
250:                        if (result.isSelected()) {
251:                            scrollPane.putClientProperty(
252:                                    SubstanceLookAndFeel.GRIP_PAINTER,
253:                                    gripPainter);
254:                            scrollPane.repaint();
255:                        }
256:                    }
257:                });
258:                return result;
259:            }
260:
261:            /**
262:             * Recursively updates the enabled state of the specified container and its
263:             * children.
264:             * 
265:             * @param c
266:             *            Container.
267:             * @param enabled
268:             *            New value for the enabled status.
269:             */
270:            void updateEnabledState(Container c, boolean enabled) {
271:                for (int counter = c.getComponentCount() - 1; counter >= 0; counter--) {
272:                    Component child = c.getComponent(counter);
273:
274:                    child.setEnabled(enabled);
275:                    if (child instanceof  Container) {
276:                        updateEnabledState((Container) child, enabled);
277:                    }
278:                }
279:            }
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.