Source Code Cross Referenced for ProgressBarPanel.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.TitledBorder;
038:
039:        import org.jvnet.lafwidget.LafWidgetUtilities;
040:        import org.jvnet.lafwidget.animation.*;
041:
042:        /**
043:         * Test application panel for testing {@link JProgressBar} component.
044:         * 
045:         * @author Kirill Grouchnikov
046:         */
047:        public class ProgressBarPanel extends JPanel {
048:            @RunOnEDT
049:            private final class ProgressBarFadeTrackerAdapter extends
050:                    FadeTrackerAdapter {
051:                @Override
052:                public void fadePerformed(FadeKind fadeKind, float fadeCycle10) {
053:                    delta(ProgressBarPanel.this , 1);
054:                }
055:            }
056:
057:            /**
058:             * ID of the looping task that updates the progress bars.
059:             */
060:            private long progressFadeId;
061:
062:            /**
063:             * Custom fade kind for updating the progress bars.
064:             */
065:            private static final FadeKind PROGRESS_FADE = new FadeKind(
066:                    "substancelaf.testApp.progress", true);
067:
068:            /**
069:             * Button that starts the update of progress bars.
070:             */
071:            private JButton startButton;
072:
073:            /**
074:             * Button that stops the update of progress bars.
075:             */
076:            private JButton stopButton;
077:
078:            /**
079:             * Creates a new panel with progress bars.
080:             */
081:            public ProgressBarPanel() {
082:                this .setLayout(new BorderLayout());
083:
084:                JPanel bars = new ScrollablePanel();
085:                GridLayout gLayout = new GridLayout(1, 2);
086:                gLayout.setHgap(5);
087:                gLayout.setVgap(5);
088:                bars.setLayout(gLayout);
089:
090:                JPanel horizPanel = new JPanel();
091:                horizPanel
092:                        .setLayout(new BoxLayout(horizPanel, BoxLayout.Y_AXIS));
093:                bars.add(horizPanel);
094:
095:                JPanel vertPanel = new JPanel();
096:                vertPanel.setLayout(new BoxLayout(vertPanel, BoxLayout.X_AXIS));
097:                bars.add(vertPanel);
098:
099:                JProgressBar determinateEnHor = new JProgressBar(
100:                        JProgressBar.HORIZONTAL, 0, 100);
101:                determinateEnHor.setIndeterminate(false);
102:                JPanel dehPanel = new JPanel();
103:                dehPanel.add(determinateEnHor);
104:                dehPanel.setBorder(new TitledBorder("Determ enabled"));
105:
106:                JProgressBar determinateEnHorStr = new JProgressBar(
107:                        JProgressBar.HORIZONTAL, 0, 100);
108:                determinateEnHorStr.setIndeterminate(false);
109:                determinateEnHorStr.setStringPainted(true);
110:                JPanel dehsPanel = new JPanel();
111:                dehsPanel.add(determinateEnHorStr);
112:                dehsPanel.setBorder(new TitledBorder("Determ enabled string"));
113:
114:                JProgressBar indeterminateEnHor = new JProgressBar(
115:                        JProgressBar.HORIZONTAL, 0, 100);
116:                indeterminateEnHor.setIndeterminate(true);
117:                indeterminateEnHor.setStringPainted(true);
118:                indeterminateEnHor.setString("In progress");
119:                JPanel iehPanel = new JPanel();
120:                iehPanel.add(indeterminateEnHor);
121:                iehPanel.setBorder(new TitledBorder("Indeterm enabled"));
122:
123:                horizPanel.add(dehPanel);
124:                horizPanel.add(dehsPanel);
125:                horizPanel.add(iehPanel);
126:
127:                JProgressBar determinateDisHor = new JProgressBar(
128:                        JProgressBar.HORIZONTAL, 0, 100);
129:                determinateDisHor.setIndeterminate(false);
130:                determinateDisHor.setEnabled(false);
131:                JPanel ddhPanel = new JPanel();
132:                ddhPanel.add(determinateDisHor);
133:                ddhPanel.setBorder(new TitledBorder("Determ disabled"));
134:
135:                JProgressBar determinateDisHorStr = new JProgressBar(
136:                        JProgressBar.HORIZONTAL, 0, 100);
137:                determinateDisHorStr.setIndeterminate(false);
138:                determinateDisHorStr.setEnabled(false);
139:                determinateDisHorStr.setStringPainted(true);
140:                JPanel ddhsPanel = new JPanel();
141:                ddhsPanel.add(determinateDisHorStr);
142:                ddhsPanel.setBorder(new TitledBorder("Determ disabled string"));
143:
144:                JProgressBar indeterminateDisHor = new JProgressBar(
145:                        JProgressBar.HORIZONTAL, 0, 100);
146:                indeterminateDisHor.setIndeterminate(true);
147:                indeterminateDisHor.setEnabled(false);
148:                JPanel idhPanel = new JPanel();
149:                idhPanel.add(indeterminateDisHor);
150:                idhPanel.setBorder(new TitledBorder("Indeterm disabled"));
151:
152:                horizPanel.add(ddhPanel);
153:                horizPanel.add(ddhsPanel);
154:                horizPanel.add(idhPanel);
155:
156:                JProgressBar determinateEnVer = new JProgressBar(
157:                        JProgressBar.VERTICAL, 0, 100);
158:                determinateEnVer.setIndeterminate(false);
159:                determinateEnVer.setStringPainted(true);
160:                JPanel devPanel = new JPanel();
161:                devPanel.add(determinateEnVer);
162:                devPanel.setBorder(new TitledBorder("Determ enabled"));
163:
164:                JProgressBar determinateEnVerRTL = new JProgressBar(
165:                        JProgressBar.VERTICAL, 0, 100);
166:                determinateEnVerRTL.setIndeterminate(false);
167:                determinateEnVerRTL.setStringPainted(true);
168:                determinateEnVerRTL
169:                        .setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
170:                JPanel devRtlPanel = new JPanel();
171:                devRtlPanel.add(determinateEnVerRTL);
172:                devRtlPanel.setBorder(new TitledBorder("Determ enabled RTL"));
173:
174:                JProgressBar indeterminateEnVer = new JProgressBar(
175:                        JProgressBar.VERTICAL, 0, 100);
176:                indeterminateEnVer.setIndeterminate(true);
177:                indeterminateEnVer.setStringPainted(true);
178:                indeterminateEnVer.setString("In progress");
179:                JPanel ievPanel = new JPanel();
180:                ievPanel.add(indeterminateEnVer);
181:                ievPanel.setBorder(new TitledBorder("Indeterm enabled"));
182:
183:                vertPanel.add(devPanel);
184:                vertPanel.add(devRtlPanel);
185:                vertPanel.add(ievPanel);
186:
187:                JProgressBar determinateDisVer = new JProgressBar(
188:                        JProgressBar.VERTICAL, 0, 100);
189:                determinateDisVer.setIndeterminate(false);
190:                determinateDisVer.setEnabled(false);
191:                JPanel ddvPanel = new JPanel();
192:                ddvPanel.add(determinateDisVer);
193:                ddvPanel.setBorder(new TitledBorder("Determ disabled"));
194:
195:                JProgressBar indeterminateDisVer = new JProgressBar(
196:                        JProgressBar.VERTICAL, 0, 100);
197:                indeterminateDisVer.setIndeterminate(true);
198:                indeterminateDisVer.setEnabled(false);
199:                JPanel idvPanel = new JPanel();
200:                idvPanel.add(indeterminateDisVer);
201:                idvPanel.setBorder(new TitledBorder("Indeterm disabled"));
202:
203:                vertPanel.add(ddvPanel);
204:                vertPanel.add(idvPanel);
205:
206:                this .add(new JScrollPane(bars), BorderLayout.CENTER);
207:
208:                JPanel buttons = new JPanel();
209:                buttons.setLayout(new FlowLayout(FlowLayout.CENTER));
210:                this .startButton = new JButton("start");
211:                this .startButton.addActionListener(new ActionListener() {
212:                    public void actionPerformed(ActionEvent e) {
213:                        progressFadeId = FadeTracker.getInstance()
214:                                .trackFadeLooping(
215:                                        PROGRESS_FADE,
216:                                        LafWidgetUtilities.getAnimationKind(
217:                                                ProgressBarPanel.this ).derive(
218:                                                0.2f), ProgressBarPanel.this ,
219:                                        null, false,
220:                                        new ProgressBarFadeTrackerAdapter(),
221:                                        -1, false);
222:                        startButton.setEnabled(false);
223:                        stopButton.setEnabled(true);
224:                    }
225:                });
226:
227:                this .stopButton = new JButton("stop");
228:                this .stopButton.setEnabled(false);
229:                this .stopButton.addActionListener(new ActionListener() {
230:                    public void actionPerformed(ActionEvent e) {
231:                        FadeTracker.getInstance().cancelFadeInstance(
232:                                progressFadeId);
233:                        stopButton.setEnabled(false);
234:                        startButton.setEnabled(true);
235:                    }
236:                });
237:
238:                JButton plus10Button = new JButton("plus 10");
239:                plus10Button.addActionListener(new ActionListener() {
240:                    public void actionPerformed(ActionEvent e) {
241:                        delta(ProgressBarPanel.this , 10);
242:                    }
243:                });
244:                buttons.add(plus10Button);
245:
246:                JButton minus10Button = new JButton("minus 10");
247:                minus10Button.addActionListener(new ActionListener() {
248:                    public void actionPerformed(ActionEvent e) {
249:                        delta(ProgressBarPanel.this , -10);
250:                    }
251:                });
252:                buttons.add(minus10Button);
253:
254:                JButton plus1Button = new JButton("plus 1");
255:                plus1Button.addActionListener(new ActionListener() {
256:                    public void actionPerformed(ActionEvent e) {
257:                        delta(ProgressBarPanel.this , 1);
258:                    }
259:                });
260:                buttons.add(plus1Button);
261:
262:                JButton minus1Button = new JButton("minus 1");
263:                minus1Button.addActionListener(new ActionListener() {
264:                    public void actionPerformed(ActionEvent e) {
265:                        delta(ProgressBarPanel.this , -1);
266:                    }
267:                });
268:                buttons.add(minus1Button);
269:
270:                JButton resetButton = new JButton("reset");
271:                resetButton.addActionListener(new ActionListener() {
272:                    public void actionPerformed(ActionEvent e) {
273:                        reset(ProgressBarPanel.this );
274:                    }
275:                });
276:
277:                buttons.add(this .startButton);
278:                buttons.add(this .stopButton);
279:                buttons.add(resetButton);
280:
281:                this .add(buttons, BorderLayout.SOUTH);
282:            }
283:
284:            protected static void delta(Component c, int delta) {
285:                if (c instanceof  JProgressBar) {
286:                    JProgressBar pb = (JProgressBar) c;
287:                    if (!pb.isIndeterminate()) {
288:                        int newValue = pb.getValue() + delta;
289:                        if (newValue < pb.getMinimum())
290:                            newValue = pb.getMinimum();
291:                        if (newValue > pb.getMaximum())
292:                            newValue = pb.getMaximum();
293:                        pb.setValue(newValue);
294:                    }
295:                }
296:                if (c instanceof  Container) {
297:                    Container cont = (Container) c;
298:                    for (int i = 0; i < cont.getComponentCount(); i++) {
299:                        delta(cont.getComponent(i), delta);
300:                    }
301:                }
302:            }
303:
304:            protected static void reset(Component c) {
305:                if (c instanceof  JProgressBar) {
306:                    JProgressBar pb = (JProgressBar) c;
307:                    if (!pb.isIndeterminate()) {
308:                        pb.setValue(pb.getMinimum());
309:                    }
310:                }
311:                if (c instanceof  Container) {
312:                    Container cont = (Container) c;
313:                    for (int i = 0; i < cont.getComponentCount(); i++) {
314:                        reset(cont.getComponent(i));
315:                    }
316:                }
317:            }
318:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.