Source Code Cross Referenced for OptionPane.java in  » Scripting » oscript-2.10.4 » ti » chimera » 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 » Scripting » oscript 2.10.4 » ti.chimera 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*=============================================================================
002:         *     Copyright Texas Instruments 2001. All Rights Reserved.
003:         * 
004:         *  This program is free software; you can redistribute it and/or modify
005:         *  it under the terms of the GNU General Public License as published by
006:         *  the Free Software Foundation; either version 2 of the License, or
007:         *  (at your option) any later version.
008:         * 
009:         *  This program is distributed in the hope that it will be useful,
010:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         *  GNU General Public License for more details.
013:         * 
014:         *  You should have received a copy of the GNU General Public License
015:         *  along with this program; if not, write to the Free Software
016:         *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package ti.chimera;
020:
021:        import javax.swing.*;
022:        import java.awt.Component;
023:
024:        /**
025:         * Create a modal option-pane dialog that is contained in a <code>Dialog</code>.
026:         * Developers should use this rather than <code>JOptionPane</code>.  For example:
027:         * <pre>
028:         *    OptionPane optionPane = new OptionPane( main.getWindowManager().getDialog("Input"),
029:         *                                            "Enter Some Input",
030:         *                                            OptionPane.QUESTION_MESSAGE,
031:         *                                            OptionPane.OK_CANCEL_OPTION );
032:         * 
033:         *    optionPane.setInitialSelectionValue("Foo");
034:         * 
035:         *    String result = (String)(optionPane.showModal());
036:         * </pre>
037:         * 
038:         * @author Rob Clark
039:         * @version 0.1
040:         */
041:        public class OptionPane extends JOptionPane {
042:            /**
043:             */
044:            private Dialog dialog;
045:
046:            /**
047:             * Class Constructor.  Create a <code>PLAIN_MESSAGE</code> type dialog.
048:             * 
049:             * @param dialog       the dialog to realize the option-pane within
050:             * @param message      the message to display
051:             */
052:            public OptionPane(Dialog dialog, Object message) {
053:                this (dialog, message, PLAIN_MESSAGE);
054:            }
055:
056:            /**
057:             * Class Constructor.  Create a dialog of the specified type with the default
058:             * options.
059:             * 
060:             * @param dialog       the dialog to realize the option-pane within
061:             * @param message      the message to display
062:             * @param messageType  the type of the message to display
063:             * @see #ERROR_MESSAGE message type
064:             * @see #INFORMATION_MESSAGE message type
065:             * @see #WARNING_MESSAGE message type
066:             * @see #QUESTION_MESSAGE message type
067:             * @see #PLAIN_MESSAGE message type
068:             */
069:            public OptionPane(Dialog dialog, Object message, int messageType) {
070:                this (dialog, message, messageType, DEFAULT_OPTION);
071:            }
072:
073:            /**
074:             * Class Constructor.  Create dialog with no icon.
075:             * 
076:             * @param dialog       the dialog to realize the option-pane within
077:             * @param message      the message to display
078:             * @param messageType  the type of the message to display
079:             * @param optionType   the options to display
080:             * @see #ERROR_MESSAGE message type
081:             * @see #INFORMATION_MESSAGE message type
082:             * @see #WARNING_MESSAGE message type
083:             * @see #QUESTION_MESSAGE message type
084:             * @see #PLAIN_MESSAGE message type
085:             * @see #DEFAULT_OPTION option type
086:             * @see #YES_NO_OPTION option type
087:             * @see #YES_NO_CANCEL_OPTION option type
088:             * @see #OK_CANCEL_OPTION option type
089:             */
090:            public OptionPane(Dialog dialog, Object message, int messageType,
091:                    int optionType) {
092:                this (dialog, message, messageType, optionType, null);
093:            }
094:
095:            /**
096:             * Class Constructor.  Create dialog with specified icon.
097:             * 
098:             * @param dialog       the dialog to realize the option-pane within
099:             * @param message      the message to display
100:             * @param messageType  the type of the message to display
101:             * @param optionType   the options to display
102:             * @param icon         the icon image to display
103:             * @see #ERROR_MESSAGE message type
104:             * @see #INFORMATION_MESSAGE message type
105:             * @see #WARNING_MESSAGE message type
106:             * @see #QUESTION_MESSAGE message type
107:             * @see #PLAIN_MESSAGE message type
108:             * @see #DEFAULT_OPTION option type
109:             * @see #YES_NO_OPTION option type
110:             * @see #YES_NO_CANCEL_OPTION option type
111:             * @see #OK_CANCEL_OPTION option type
112:             */
113:            public OptionPane(Dialog dialog, Object message, int messageType,
114:                    int optionType, Icon icon) {
115:                this (dialog, message, messageType, optionType, icon, null);
116:            }
117:
118:            /**
119:             * Class Constructor.
120:             * 
121:             * @param dialog       the dialog to realize the option-pane within
122:             * @param message      the message to display
123:             * @param messageType  the type of the message to display
124:             * @param optionType   the options to display
125:             * @param icon         the icon image to display
126:             * @param options      the choices the user can select
127:             * @see #ERROR_MESSAGE message type
128:             * @see #INFORMATION_MESSAGE message type
129:             * @see #WARNING_MESSAGE message type
130:             * @see #QUESTION_MESSAGE message type
131:             * @see #PLAIN_MESSAGE message type
132:             * @see #DEFAULT_OPTION option type
133:             * @see #YES_NO_OPTION option type
134:             * @see #YES_NO_CANCEL_OPTION option type
135:             * @see #OK_CANCEL_OPTION option type
136:             */
137:            public OptionPane(Dialog dialog, Object message, int messageType,
138:                    int optionType, Icon icon, Object[] options) {
139:                this (dialog, message, messageType, optionType, icon, options,
140:                        null);
141:            }
142:
143:            /**
144:             * Class Constructor.
145:             * 
146:             * @param dialog       the dialog to realize the option-pane within
147:             * @param message      the message to display
148:             * @param messageType  the type of the message to display
149:             * @param optionType   the options to display
150:             * @param icon         the icon image to display
151:             * @param options      the choices the user can select
152:             * @param initialVal   the initially selected option
153:             * @see #ERROR_MESSAGE message type
154:             * @see #INFORMATION_MESSAGE message type
155:             * @see #WARNING_MESSAGE message type
156:             * @see #QUESTION_MESSAGE message type
157:             * @see #PLAIN_MESSAGE message type
158:             * @see #DEFAULT_OPTION option type
159:             * @see #YES_NO_OPTION option type
160:             * @see #YES_NO_CANCEL_OPTION option type
161:             * @see #OK_CANCEL_OPTION option type
162:             */
163:            public OptionPane(Dialog dialog, Object message, int messageType,
164:                    int optionType, Icon icon, Object[] options,
165:                    Object initialVal) {
166:                super (message, messageType, optionType, icon, options,
167:                        initialVal);
168:
169:                this .dialog = dialog;
170:
171:                if (((options != null) && (options.length > 0))
172:                        || (initialVal != null))
173:                    setWantsInput(true);
174:                else
175:                    setWantsInput(false);
176:
177:                dialog.getContentPane().add(this );
178:                dialog.pack();
179:                dialog.center();
180:
181:                class CloseDialogPropertyChangeListener implements 
182:                        java.beans.PropertyChangeListener {
183:                    private Dialog dialog;
184:
185:                    CloseDialogPropertyChangeListener(Dialog dialog) {
186:                        this .dialog = dialog;
187:                    }
188:
189:                    public void propertyChange(
190:                            java.beans.PropertyChangeEvent event) {
191:                        if (event.getSource() == OptionPane.this 
192:                                && (event.getPropertyName().equals(
193:                                        VALUE_PROPERTY) || event
194:                                        .getPropertyName().equals(
195:                                                INPUT_VALUE_PROPERTY))) {
196:                            dialog.setVisible(false);
197:                            dialog.dispose();
198:                        }
199:                    }
200:                }
201:
202:                addPropertyChangeListener(new CloseDialogPropertyChangeListener(
203:                        dialog));
204:            }
205:
206:            /**
207:             * Show the option-pane dialog.  Do not return until the dialog is closed.
208:             * 
209:             * @return the input value
210:             */
211:            public Object showModal() {
212:                dialog.setVisible(true);
213:                dialog.showModal();
214:
215:                Object value = getInputValue();
216:
217:                dialog.dispose();
218:
219:                if (value == UNINITIALIZED_VALUE)
220:                    return null;
221:
222:                return value;
223:            }
224:        }
225:
226:        /*
227:         *   Local Variables:
228:         *   tab-width: 2
229:         *   indent-tabs-mode: nil
230:         *   mode: java
231:         *   c-indentation-style: java
232:         *   eval: (c-set-offset 'substatement-open '0)
233:         *   c-basic-offset: 2
234:         *   End:
235:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.