Source Code Cross Referenced for DualTextEntryDialog.java in  » Content-Management-System » harmonise » org » openharmonise » swing » 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 » Content Management System » harmonise » org.openharmonise.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.swing;
020:
021:        import java.awt.*;
022:        import java.awt.event.*;
023:
024:        import javax.swing.*;
025:
026:        import org.openharmonise.vfs.context.*;
027:        import org.openharmonise.vfs.gui.*;
028:
029:        /**
030:         * 
031:         * @author Matthew Large
032:         * @version $Revision: 1.1 $
033:         *
034:         */
035:        public class DualTextEntryDialog extends JDialog implements 
036:                KeyListener, LayoutManager, ActionListener, ContextListener {
037:
038:            private JButton m_okButton = null;
039:            private JButton m_cancelButton = null;
040:
041:            private JTextField m_textfield1 = null;
042:            private JLabel m_caption1 = null;
043:
044:            private JTextField m_textfield2 = null;
045:            private JLabel m_caption2 = null;
046:
047:            private JLabel m_label = null;
048:
049:            /**
050:             * 
051:             */
052:            private void setup() {
053:                ContextHandler.getInstance().addListener(
054:                        ContextType.CONTEXT_APP_FOCUS, this );
055:
056:                this .setResizable(false);
057:
058:                this .getContentPane().setLayout(this );
059:
060:                this .setSize(400, 170);
061:                int x = this .getGraphicsConfiguration().getBounds().width / 2
062:                        - this .getSize().width / 2;
063:                int y = this .getGraphicsConfiguration().getBounds().height / 2
064:                        - this .getSize().height / 2;
065:
066:                this .setLocation(x, y);
067:
068:                this .m_textfield1 = new JTextField();
069:                this .m_textfield1.addKeyListener(this );
070:                this .getContentPane().add(this .m_textfield1);
071:
072:                this .m_caption1 = new JLabel();
073:                this .getContentPane().add(this .m_caption1);
074:
075:                this .m_textfield2 = new JTextField();
076:                this .m_textfield2.addKeyListener(this );
077:                this .getContentPane().add(this .m_textfield2);
078:
079:                this .m_caption2 = new JLabel();
080:                this .getContentPane().add(this .m_caption2);
081:
082:                String fontName = "Dialog";
083:                int fontSize = 11;
084:                Font font = new Font(fontName, Font.PLAIN, fontSize);
085:                this .getContentPane().setBackground(new Color(224, 224, 224));
086:
087:                m_okButton = new JButton("OK");
088:                m_okButton.setActionCommand("OK");
089:                m_okButton.setFont(font);
090:                m_okButton.addActionListener(this );
091:                this .getContentPane().add(m_okButton);
092:
093:                m_cancelButton = new JButton("Cancel");
094:                m_cancelButton.setActionCommand("CANCEL");
095:                m_cancelButton.setFont(font);
096:                m_cancelButton.addActionListener(this );
097:                this .getContentPane().add(m_cancelButton);
098:            }
099:
100:            public void setLabelText(String sLabel) {
101:                String fontName = "Dialog";
102:                int fontSize = 11;
103:                Font font = new Font(fontName, Font.PLAIN, fontSize);
104:
105:                this .m_label = new JLabel(sLabel);
106:                this .m_label.setFont(font);
107:                this .getContentPane().add(this .m_label);
108:                this .setSize(300, 190);
109:            }
110:
111:            public void setLabelColor(Color color) {
112:                if (this .m_label != null) {
113:                    this .m_label.setForeground(color);
114:                }
115:            }
116:
117:            public static void main(String[] args) {
118:
119:                JFrame frame = new JFrame();
120:                frame.setIconImage(((ImageIcon) IconManager.getInstance()
121:                        .getIcon("32-sim-logo.gif")).getImage());
122:
123:                SingleTextEntryDialog dialog = new SingleTextEntryDialog(frame,
124:                        "Rename");
125:                dialog.show();
126:
127:                dialog = new SingleTextEntryDialog(frame, "Warning");
128:                dialog
129:                        .setLabelText("Some label text sd fsd ds fsd fs dfds dsfs dfs fds dfsd fds fsd sd sd .");
130:                dialog.show();
131:            }
132:
133:            /**
134:             * @param arg0
135:             * @throws java.awt.HeadlessException
136:             */
137:            private DualTextEntryDialog(Frame arg0) throws HeadlessException {
138:                super (arg0, true);
139:            }
140:
141:            /**
142:             * @throws java.awt.HeadlessException
143:             */
144:            private DualTextEntryDialog() throws HeadlessException {
145:                super ();
146:            }
147:
148:            /**
149:             * @param arg0
150:             * @throws java.awt.HeadlessException
151:             */
152:            private DualTextEntryDialog(Dialog arg0) throws HeadlessException {
153:                super (arg0);
154:            }
155:
156:            /**
157:             * @param arg0
158:             * @param arg1
159:             * @throws java.awt.HeadlessException
160:             */
161:            private DualTextEntryDialog(Dialog arg0, boolean arg1)
162:                    throws HeadlessException {
163:                super (arg0, arg1);
164:            }
165:
166:            /**
167:             * @param arg0
168:             * @param arg1
169:             * @throws java.awt.HeadlessException
170:             */
171:            private DualTextEntryDialog(Frame arg0, boolean arg1)
172:                    throws HeadlessException {
173:                super (arg0, arg1);
174:            }
175:
176:            /**
177:             * @param arg0
178:             * @param arg1
179:             * @throws java.awt.HeadlessException
180:             */
181:            private DualTextEntryDialog(Dialog arg0, String arg1)
182:                    throws HeadlessException {
183:                super (arg0, arg1);
184:            }
185:
186:            /**
187:             * @param arg0
188:             * @param arg1
189:             * @param arg2
190:             * @throws java.awt.HeadlessException
191:             */
192:            private DualTextEntryDialog(Dialog arg0, String arg1, boolean arg2)
193:                    throws HeadlessException {
194:                super (arg0, arg1, arg2);
195:            }
196:
197:            /**
198:             * @param arg0
199:             * @param arg1
200:             * @throws java.awt.HeadlessException
201:             */
202:            public DualTextEntryDialog(Frame arg0, String arg1)
203:                    throws HeadlessException {
204:                super (arg0, arg1, true);
205:                this .setup();
206:            }
207:
208:            /**
209:             * @param arg0
210:             * @param arg1
211:             * @param arg2
212:             * @throws java.awt.HeadlessException
213:             */
214:            private DualTextEntryDialog(Frame arg0, String arg1, boolean arg2)
215:                    throws HeadlessException {
216:                super (arg0, arg1, arg2);
217:            }
218:
219:            /**
220:             * @param arg0
221:             * @param arg1
222:             * @param arg2
223:             * @param arg3
224:             * @throws java.awt.HeadlessException
225:             */
226:            private DualTextEntryDialog(Dialog arg0, String arg1, boolean arg2,
227:                    GraphicsConfiguration arg3) throws HeadlessException {
228:                super (arg0, arg1, arg2, arg3);
229:            }
230:
231:            /**
232:             * @param arg0
233:             * @param arg1
234:             * @param arg2
235:             * @param arg3
236:             */
237:            private DualTextEntryDialog(Frame arg0, String arg1, boolean arg2,
238:                    GraphicsConfiguration arg3) {
239:                super (arg0, arg1, arg2, arg3);
240:            }
241:
242:            /* (non-Javadoc)
243:             * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
244:             */
245:            public void removeLayoutComponent(Component arg0) {
246:
247:            }
248:
249:            /* (non-Javadoc)
250:             * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
251:             */
252:            public void layoutContainer(Container arg0) {
253:                int nHeight = 10;
254:
255:                if (this .m_label != null) {
256:                    this .m_label.setLocation(10, nHeight);
257:                    this .m_label.setSize(280, 20);
258:                    nHeight = nHeight + 20;
259:                }
260:
261:                m_caption1.setLocation(10, nHeight);
262:                m_caption1.setSize(280, 20);
263:                nHeight = nHeight + 20;
264:
265:                m_textfield1.setLocation(10, nHeight);
266:                m_textfield1.setSize(280, 20);
267:                nHeight = nHeight + 20;
268:
269:                m_caption2.setLocation(10, nHeight);
270:                m_caption2.setSize(280, 20);
271:                nHeight = nHeight + 20;
272:
273:                m_textfield2.setLocation(10, nHeight);
274:                m_textfield2.setSize(280, 20);
275:                nHeight = nHeight + 30;
276:
277:                m_okButton.setLocation(130, nHeight);
278:                m_okButton.setSize(70, 20);
279:
280:                m_cancelButton.setLocation(210, nHeight);
281:                m_cancelButton.setSize(70, 20);
282:            }
283:
284:            /* (non-Javadoc)
285:             * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
286:             */
287:            public void addLayoutComponent(String arg0, Component arg1) {
288:
289:            }
290:
291:            /* (non-Javadoc)
292:             * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
293:             */
294:            public Dimension minimumLayoutSize(Container arg0) {
295:                return this .getSize();
296:            }
297:
298:            /* (non-Javadoc)
299:             * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
300:             */
301:            public Dimension preferredLayoutSize(Container arg0) {
302:                return this .getSize();
303:            }
304:
305:            /* (non-Javadoc)
306:             * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
307:             */
308:            public void actionPerformed(ActionEvent ae) {
309:                if (ae.getActionCommand().equals("OK")) {
310:                    // NO-OP
311:                } else if (ae.getActionCommand().equals("CANCEL")) {
312:                    this .setText1Value("");
313:                    this .setText2Value("");
314:                }
315:                ContextHandler.getInstance().removeListener(
316:                        ContextType.CONTEXT_APP_FOCUS, this );
317:                this .hide();
318:            }
319:
320:            public void setCaption1(String string) {
321:                this .m_caption1.setText(string);
322:            }
323:
324:            public void setCaption2(String string) {
325:                this .m_caption2.setText(string);
326:            }
327:
328:            /**
329:             * @param string
330:             */
331:            public void setText2Value(String string) {
332:                this .m_textfield2.setText(string);
333:            }
334:
335:            public String getText2Value() {
336:                return this .m_textfield2.getText().trim();
337:            }
338:
339:            /**
340:             * @param string
341:             */
342:            public void setText1Value(String string) {
343:                this .m_textfield1.setText(string);
344:            }
345:
346:            public String getText1Value() {
347:                return this .m_textfield1.getText().trim();
348:            }
349:
350:            /* (non-Javadoc)
351:             * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
352:             */
353:            public void keyPressed(KeyEvent ke) {
354:                if (ke.getKeyCode() == KeyEvent.VK_ENTER) {
355:                    this .hide();
356:                }
357:            }
358:
359:            /* (non-Javadoc)
360:             * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
361:             */
362:            public void keyReleased(KeyEvent arg0) {
363:            }
364:
365:            /* (non-Javadoc)
366:             * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
367:             */
368:            public void keyTyped(KeyEvent arg0) {
369:            }
370:
371:            /* (non-Javadoc)
372:             * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
373:             */
374:            public void contextMessage(ContextEvent ce) {
375:                if (ce.CONTEXT_TYPE == ContextType.CONTEXT_APP_FOCUS) {
376:                    this.toFront();
377:                }
378:            }
379:
380:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.