Source Code Cross Referenced for Dialog.java in  » Web-Framework » ThinWire » thinwire » ui » 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 » Web Framework » ThinWire » thinwire.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        #IFNDEF ALT_LICENSE
003:                                   ThinWire(R) RIA Ajax Framework
004:                         Copyright (C) 2003-2007 Custom Credit Systems
005:
006:          This library is free software; you can redistribute it and/or modify it under
007:          the terms of the GNU Lesser General Public License as published by the Free
008:          Software Foundation; either version 2.1 of the License, or (at your option) any
009:          later version.
010:
011:          This library is distributed in the hope that it will be useful, but WITHOUT ANY
012:          WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
013:          PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
014:
015:          You should have received a copy of the GNU Lesser General Public License along
016:          with this library; if not, write to the Free Software Foundation, Inc., 59
017:          Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:
019:          Users who would rather have a commercial license, warranty or support should
020:          contact the following company who invented, built and supports the technology:
021:          
022:                        Custom Credit Systems, Richardson, TX 75081, USA.
023:           	            email: info@thinwire.com    ph: +1 (888) 644-6405
024:         	                        http://www.thinwire.com
025:        #ENDIF
026:         [ v1.2_RC2 ] 
027:         */
028:        package thinwire.ui;
029:
030:        /**
031:         * A Dialog is a window with a title that is usually associated to a Frame.
032:         * <p>
033:         * <b>Example:</b> <br>
034:         * <img src="doc-files/Dialog-1.png"> <br>
035:         * 
036:         * <pre>
037:         * Dialog dlg = new Dialog(&quot;Dialog Test&quot;);
038:         * dlg.setBounds(25, 25, 600, 400);
039:         * 
040:         * final TextField tBox = new TextField();
041:         * tBox.setBounds(25, 25, 150, 20);
042:         * dlg.getChildren().add(tBox);
043:         * 
044:         * final Button btn1 = new Button(&quot;Add Text&quot;);
045:         * btn1.setBounds(200, 20, 100, 30);
046:         * dlg.getChildren().add(btn1);
047:         * 
048:         * final Button btn2 = new Button(&quot;Numeric Mask&quot;);
049:         * btn2.setBounds(310, 20, 100, 30);
050:         * dlg.getChildren().add(btn2);
051:         * 
052:         * final Button btn3 = new Button(&quot;Right Align&quot;);
053:         * btn3.setBounds(420, 20, 100, 30);
054:         * dlg.getChildren().add(btn3);
055:         * 
056:         * ActionListener clickListener = new ActionListener() {
057:         *     public void actionPerformed(ActionEvent e) {
058:         *         Button btn = (Button) e.getSource();
059:         * 
060:         *         if (btn == btn1) {
061:         *             tBox.setText(tBox.getText() + &quot;913JQP-&quot;);
062:         *         } else if (btn == btn2) {
063:         *             tBox.setEditMask(&quot;#########&quot;);
064:         *         } else if (btn == btn3) {
065:         *             tBox.setAlignX(AlignX.RIGHT);
066:         *         }
067:         *     }
068:         * };
069:         * 
070:         * btn1.addActionListener(Button.ACTION_CLICK, clickListener);
071:         * btn2.addActionListener(Button.ACTION_CLICK, clickListener);
072:         * btn3.addActionListener(Button.ACTION_CLICK, clickListener);
073:         * 
074:         * Divider dv = new Divider();
075:         * dv.setBounds(25, 70, 550, 5);
076:         * dlg.getChildren().add(dv);
077:         * 
078:         * final TextArea ta = new TextArea();
079:         * ta.setBounds(25, 100, 350, 200);
080:         * dlg.getChildren().add(ta);
081:         * 
082:         * Button btn4 = new Button(&quot;Add Text&quot;);
083:         * btn4.setBounds(420, 100, 100, 30);
084:         * dlg.getChildren().add(btn4);
085:         * btn4.addActionListener(Button.ACTION_CLICK, new ActionListener() {
086:         *     public void actionPerformed(ActionEvent e) {
087:         *         ta.setText(ta.getText() + &quot;913JQP-&quot;);
088:         *     }
089:         * });
090:         * 
091:         * dlg.setVisible(true);
092:         * </pre>
093:         * 
094:         * </p>
095:         * <p>
096:         * @author Joshua J. Gertzen
097:         */
098:        public class Dialog extends AbstractWindow {
099:            public static final String PROPERTY_RESIZE_ALLOWED = "resizeAllowed";
100:            public static final String PROPERTY_REPOSITION_ALLOWED = "repositionAllowed";
101:            public static final String PROPERTY_MODAL = "modal";
102:            public static final String PROPERTY_WAIT_FOR_WINDOW = "waitForWindow";
103:
104:            private static final int TITLE_BAR_HEIGHT = 18 + 1;
105:
106:            private boolean resizeAllowed;
107:            private boolean repositionAllowed = true;
108:            private boolean modal = true;
109:            boolean waitForWindow;
110:
111:            /**
112:             * Constructs a new Dialog with no title. 
113:             */
114:            public Dialog() {
115:                this (null);
116:            }
117:
118:            /**
119:             * Constructs a new Dialog with the specified title.
120:             * @param title the title to display.
121:             */
122:            public Dialog(String title) {
123:                setTitle(title);
124:                setWidth(320);
125:                setHeight(240);
126:            }
127:
128:            /**
129:             * Returns whether the Dialog can be resized by dragging the bottom-right
130:             * corner.
131:             * 
132:             * @return true if the Dialog can be resized
133:             */
134:            public boolean isResizeAllowed() {
135:                return resizeAllowed;
136:            }
137:
138:            /**
139:             * Set whether the Dialog can be resized by dragin the bottom-right corner.
140:             * 
141:             * @param resizeAllowed (Default = false)
142:             */
143:            public void setResizeAllowed(boolean resizeAllowed) {
144:                boolean oldResizeAllowed = this .resizeAllowed;
145:                this .resizeAllowed = resizeAllowed;
146:                firePropertyChange(this , PROPERTY_RESIZE_ALLOWED,
147:                        oldResizeAllowed, this .resizeAllowed);
148:            }
149:
150:            /**
151:             * Returns whether the Dialog can be drug around the frame
152:             * 
153:             * @return true is the Diagog is draggable
154:             */
155:            public boolean isRepositionAllowed() {
156:                return repositionAllowed;
157:            }
158:
159:            /**
160:             * Set whether the Dialog can be drug around the screen.
161:             * 
162:             * @param repositionAllowed (Default = true)
163:             */
164:            public void setRepositionAllowed(boolean repositionAllowed) {
165:                boolean oldRepositionAllowed = this .repositionAllowed;
166:                this .repositionAllowed = repositionAllowed;
167:                firePropertyChange(this , PROPERTY_REPOSITION_ALLOWED,
168:                        oldRepositionAllowed, this .repositionAllowed);
169:            }
170:
171:            /**
172:             * Returns whether the Dialog is modal.
173:             * @return true if the Dialog is modal
174:             */
175:            public boolean isModal() {
176:                return modal;
177:            }
178:
179:            /**
180:             * Set whether the Dialog is modal. If the Dialog is modal, when it is
181:             * visible, all other components are prevented from receiving actions.
182:             * 
183:             * @param modal (Default = true)
184:             */
185:            public void setModal(boolean modal) {
186:                if (this .isVisible())
187:                    throw new IllegalStateException(
188:                            "You cannot change the modal state of a visible Dialog");
189:                boolean oldModal = this .modal;
190:                this .modal = modal;
191:                firePropertyChange(this , PROPERTY_MODAL, oldModal, this .modal);
192:            }
193:
194:            public int getInnerHeight() {
195:                int innerHeight = super .getInnerHeight() - TITLE_BAR_HEIGHT
196:                        - (getMenu() == null ? 0 : MENU_BAR_HEIGHT);
197:                return innerHeight < 0 ? 0 : innerHeight;
198:            }
199:
200:            /**
201:             * Returns whether the Dialog will block execution when visible.
202:             * 
203:             * @return
204:             */
205:            public boolean isWaitForWindow() {
206:                return this .waitForWindow;
207:            }
208:
209:            /**
210:             * Sets whether setting the visible property to true will cause this thread to block.
211:             * @param waitForWindow (Default = false)
212:             */
213:            public void setWaitForWindow(boolean waitForWindow) {
214:                if (this .waitForWindow == waitForWindow)
215:                    return;
216:                boolean oldWaitForWindow = this .waitForWindow;
217:                this .waitForWindow = waitForWindow;
218:                firePropertyChange(this , PROPERTY_WAIT_FOR_WINDOW,
219:                        oldWaitForWindow, waitForWindow);
220:
221:                if (isVisible()) {
222:                    if (oldWaitForWindow) {
223:                        Application.current().releaseThread();
224:                    } else {
225:                        Application.current().captureThread();
226:                    }
227:                }
228:            }
229:
230:            /**
231:             * Makes the Dialog visible.
232:             * @see thinwire.ui.Component#setVisible(boolean)
233:             * @param visible (Default = false)
234:             */
235:            public void setVisible(boolean visible) {
236:                if (isVisible() != visible) {
237:                    Application app = Application.current();
238:                    Frame f = app.getFrame();
239:                    f.dialogVisibilityChanged(this , visible);
240:
241:                    if (visible) {
242:                        app.showWindow(this );
243:                        super .setVisible(visible);
244:                        if (waitForWindow)
245:                            app.captureThread();
246:                    } else {
247:                        app.hideWindow(this );
248:                        super .setVisible(false);
249:                        if (waitForWindow)
250:                            app.releaseThread();
251:                    }
252:                }
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.