Source Code Cross Referenced for CleverPHLConfirmDialog.java in  » Testing » jacareto » jacareto » cleverphl » gui » 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 » Testing » jacareto » jacareto.cleverphl.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto 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 GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.cleverphl.gui;
025:
026:        import jacareto.cleverphl.CleverPHL;
027:
028:        import java.awt.BorderLayout;
029:        import java.awt.Dialog;
030:        import java.awt.Frame;
031:        import java.awt.Point;
032:        import java.awt.Window;
033:        import java.awt.event.ActionEvent;
034:        import java.awt.event.ActionListener;
035:
036:        import javax.swing.JButton;
037:        import javax.swing.JDialog;
038:        import javax.swing.JLabel;
039:        import javax.swing.JPanel;
040:        import javax.swing.border.EmptyBorder;
041:
042:        /**
043:         * A Message Dialog with a line of text (the message) and two buttons, a "yes" and a "no" button.
044:         * 
045:         * <p>
046:         * This dialog is modal and not resizable. It is set to the middle of the screen.
047:         * </p>
048:         * 
049:         * <p>
050:         * After the dialog has been closed, the method {@link #getValue()} returns the value
051:         * <code>YES</code> or <code>NO</code>.
052:         * </p>
053:         *
054:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
055:         * @version 0.9
056:         */
057:        public class CleverPHLConfirmDialog extends JDialog implements 
058:                ActionListener {
059:            /** The value for the pressed <code>YES</code> button. */
060:            public static final int YES = 0;
061:
062:            /** The value for the pressed <code>NO</code> button. */
063:            public static final int NO = 1;
064:
065:            /** The CleverPHL instance. */
066:            private CleverPHL cleverPHL;
067:
068:            /** The chosen value. */
069:            private int value;
070:
071:            /** The "yes"-button. */
072:            private JButton yesButton;
073:
074:            /** The "no"-button. */
075:            private JButton noButton;
076:
077:            /**
078:             * Creates a new confirm dialog with a specified title, owner frame, message, "yes"-button text
079:             * and "no"-button text. The dialog is set visible in this constructor.
080:             *
081:             * @param cleverPHL the CleverPHL instance
082:             * @param owner The frame which is the owner of this dialog
083:             * @param title The title of the dialog
084:             * @param message The message
085:             * @param yesButtonText The text of the "yes"-button
086:             * @param noButtonText The text of the "no"-button
087:             */
088:            public CleverPHLConfirmDialog(CleverPHL cleverPHL, Frame owner,
089:                    String title, String message, String yesButtonText,
090:                    String noButtonText) {
091:                super (owner, title, true);
092:                this .cleverPHL = cleverPHL;
093:                setLocation(owner);
094:                create(message, yesButtonText, noButtonText);
095:            }
096:
097:            /**
098:             * Creates a new confirm dialog with a specified title, owner dialog, message, "yes"-button
099:             * text and "no"-button text. The dialog is set visible in this constructor.
100:             *
101:             * @param cleverPHL the CleverPHL instance
102:             * @param owner The frame which is the owner of this dialog
103:             * @param title The title of the frame
104:             * @param message The message
105:             * @param yesButtonText The text of the "yes"-button
106:             * @param noButtonText The text of the "no"-button
107:             */
108:            public CleverPHLConfirmDialog(CleverPHL cleverPHL, Dialog owner,
109:                    String title, String message, String yesButtonText,
110:                    String noButtonText) {
111:                super (owner, title, true);
112:                this .cleverPHL = cleverPHL;
113:                setLocation(owner);
114:                create(message, yesButtonText, noButtonText);
115:            }
116:
117:            /**
118:             * Creates the components and the layout of the dialog.
119:             *
120:             * @param message the message to be displayed
121:             * @param yesButtonText The text of the "yes"-button
122:             * @param noButtonText The text of the "no"-button
123:             */
124:            private void create(String message, String yesButtonText,
125:                    String noButtonText) {
126:                setName(cleverPHL.getCustomization().getString(
127:                        "Components.JacaretoComponent", "JACARETO_COMPONENT"));
128:
129:                // creating the buttons
130:                yesButton = new JButton(yesButtonText);
131:                yesButton.addActionListener(this );
132:                noButton = new JButton(noButtonText);
133:                noButton.addActionListener(this );
134:
135:                getContentPane().setLayout(new BorderLayout());
136:
137:                JPanel labelPanel = new JPanel();
138:                labelPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
139:                labelPanel.add(new JLabel(message));
140:                getContentPane().add(labelPanel, BorderLayout.NORTH);
141:
142:                JPanel buttonPanel = new JPanel();
143:                buttonPanel.add(yesButton);
144:                buttonPanel.add(noButton);
145:                buttonPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
146:                getContentPane().add(buttonPanel, BorderLayout.SOUTH);
147:                pack();
148:                setResizable(false);
149:                setVisible(true);
150:            }
151:
152:            /**
153:             * Sets the location of the message dialog relativ to the owners position
154:             *
155:             * @param owner the owner
156:             */
157:            public void setLocation(Window owner) {
158:                Point ownerLoc = owner.getLocation();
159:                setLocation(((int) ownerLoc.getX()) + 20, ((int) ownerLoc
160:                        .getY()) + 20);
161:            }
162:
163:            /**
164:             * Returns the value of the confirm dialog.
165:             *
166:             * @return <code>YES</code> if the "yes"-button has been pressed, <code>NO</code> if the
167:             *         "no"-button has been pressed.
168:             */
169:            public int getValue() {
170:                return value;
171:            }
172:
173:            /**
174:             * Invoked when the button was pressed.
175:             *
176:             * @param e The action event
177:             */
178:            public void actionPerformed(ActionEvent e) {
179:                if (e.getSource() == yesButton) {
180:                    value = YES;
181:                } else {
182:                    value = NO;
183:                }
184:
185:                dispose();
186:            }
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.