Source Code Cross Referenced for WizardPanel.java in  » Development » RetroGuard » COM » rl » util » 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 » Development » RetroGuard » COM.rl.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ===========================================================================
002:         * $RCSfile: WizardPanel.java,v $
003:         * ===========================================================================
004:         *
005:         * RetroGuard -- an obfuscation package for Java classfiles.
006:         *
007:         * Copyright (c) 1998-2006 Mark Welsh (markw@retrologic.com)
008:         *
009:         * This program can be redistributed and/or modified under the terms of the 
010:         * Version 2 of the GNU General Public License as published by the Free 
011:         * Software Foundation.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
016:         * GNU General Public License for more details.
017:         *
018:         */
019:
020:        package COM.rl.util;
021:
022:        import java.io.*;
023:        import java.util.*;
024:        import java.awt.*;
025:        import java.awt.event.*;
026:
027:        /**
028:         * A Panel which contains a CardLayout of other Components with prev/next/finish
029:         * buttons -- used for 'wizards'.
030:         *
031:         * @author      Mark Welsh
032:         */
033:        public class WizardPanel extends Panel {
034:            // Constants -------------------------------------------------------------
035:
036:            // Fields ----------------------------------------------------------------
037:            public Panel cards;
038:            public Panel buttonCards;
039:            private int cardShown = 0;
040:            private int cardCount = 0;
041:            private Button finishButton;
042:            private Label statusField;
043:
044:            // Class Methods ---------------------------------------------------------
045:
046:            // Instance Methods ------------------------------------------------------
047:            /** Ctor. */
048:            public WizardPanel(Panel[] panels,
049:                    ActionListener firstNextListener,
050:                    ActionListener finishListener) {
051:                // Background color to dialog-gray
052:                setBackground(Color.lightGray);
053:
054:                // Set up the CardLayout with 'prev'/'next'/'finish' buttons.
055:                setLayout(new BorderLayout());
056:
057:                // (cards)
058:                cards = new Panel();
059:                cards.setLayout(new CardLayout());
060:                for (int i = 0; i < panels.length; i++) {
061:                    cards.add(Integer.toString(i), panels[i]);
062:                }
063:                cardCount = panels.length;
064:                showPanelCard();
065:
066:                // (buttons)
067:                buttonCards = new Panel();
068:                buttonCards.setLayout(new CardLayout());
069:
070:                Panel buttonsPanelFirst = new Panel();
071:                buttonsPanelFirst.setLayout(new FlowLayout(FlowLayout.RIGHT));
072:                Button nextButton = new Button("next>");
073:                nextButton.addActionListener(firstNextListener);
074:                buttonsPanelFirst.add(nextButton);
075:
076:                Panel buttonsPanelNormal = new Panel();
077:                buttonsPanelNormal.setLayout(new FlowLayout(FlowLayout.RIGHT));
078:                Button prevButton = new Button("<prev");
079:                nextButton = new Button("next>");
080:                prevButton.addActionListener(new ActionListener() {
081:                    public void actionPerformed(ActionEvent e) {
082:                        previousCard();
083:                    }
084:                });
085:                nextButton.addActionListener(new ActionListener() {
086:                    public void actionPerformed(ActionEvent e) {
087:                        nextCard();
088:                    }
089:                });
090:                buttonsPanelNormal.add(prevButton);
091:                buttonsPanelNormal.add(nextButton);
092:
093:                Panel buttonsPanelLast = new Panel();
094:                buttonsPanelLast.setLayout(new FlowLayout(FlowLayout.RIGHT));
095:                prevButton = new Button("<prev");
096:                finishButton = new Button("finish");
097:                prevButton.addActionListener(new ActionListener() {
098:                    public void actionPerformed(ActionEvent e) {
099:                        previousCard();
100:                    }
101:                });
102:                finishButton.addActionListener(finishListener);
103:                buttonsPanelLast.add(prevButton);
104:                buttonsPanelLast.add(finishButton);
105:
106:                buttonCards.add("first", buttonsPanelFirst);
107:                buttonCards.add("normal", buttonsPanelNormal);
108:                buttonCards.add("last", buttonsPanelLast);
109:                showButtonCard();
110:
111:                // A status bar to the left of the flip buttons
112:                statusField = new Label(
113:                        "                                                                     ");
114:                statusField.setBackground(Color.lightGray);
115:                statusField.setFont(new Font("Helvetica", Font.PLAIN, 12));
116:                Panel statusBorder = new Panel() {
117:                    public void paint(Graphics g) {
118:                        g.setColor(Color.lightGray);
119:                        g.draw3DRect(6, 6, getSize().width - 12,
120:                                getSize().height - 12, false);
121:                    }
122:                };
123:                statusBorder.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 7));
124:                statusBorder.add(statusField);
125:                Panel lower = new Panel();
126:                GridBagLayout gridbag = new GridBagLayout();
127:                GridBagConstraints c = new GridBagConstraints();
128:                lower.setLayout(gridbag);
129:                c.fill = GridBagConstraints.BOTH;
130:                c.weightx = 1.0;
131:                c.insets = new Insets(4, 4, 4, 4);
132:                c.gridwidth = 1;
133:                gridbag.setConstraints(statusBorder, c);
134:                lower.add(statusBorder);
135:                c.weightx = 0.0;
136:                c.gridwidth = GridBagConstraints.REMAINDER; //end of row
137:                gridbag.setConstraints(buttonCards, c);
138:                lower.add(buttonCards);
139:
140:                add("South", lower);
141:                add("Center", cards);
142:            }
143:
144:            /** Flip from first to second card. */
145:            public void flipFirst() {
146:                nextCard();
147:            }
148:
149:            /** Activate the finish button? */
150:            public void setFinishEnabled(boolean active) {
151:                finishButton.setEnabled(active);
152:            }
153:
154:            /** Set the status field */
155:            public void setStatus(String status) {
156:                statusField.setText(status);
157:            }
158:
159:            // Flip to previous card.
160:            void previousCard() {
161:                if (cardShown > 0) {
162:                    cardShown--;
163:                    showButtonCard();
164:                    showPanelCard();
165:                }
166:            }
167:
168:            // Flip to next card.
169:            void nextCard() {
170:                if (cardShown < cardCount - 1) {
171:                    cardShown++;
172:                    showButtonCard();
173:                    showPanelCard();
174:                }
175:            }
176:
177:            // Show the appropriate panel.
178:            private void showPanelCard() {
179:                ((CardLayout) cards.getLayout()).show(cards, Integer
180:                        .toString(cardShown));
181:            }
182:
183:            // Show the appropriate buttons.
184:            private void showButtonCard() {
185:                if (cardShown == cardCount - 1) {
186:                    ((CardLayout) buttonCards.getLayout()).show(buttonCards,
187:                            "last");
188:                } else if (cardShown == 0) {
189:                    ((CardLayout) buttonCards.getLayout()).show(buttonCards,
190:                            "first");
191:                } else {
192:                    ((CardLayout) buttonCards.getLayout()).show(buttonCards,
193:                            "normal");
194:                }
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.