Source Code Cross Referenced for SplashWindow.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3dfly » utils » 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 » 6.0 JDK Modules » java 3d » org.jdesktop.j3dfly.utils.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/utils/gui/SplashWindow.java,v 1.2 2007/01/29 18:42:03 paulby Exp $
003:         *
004:         *                         Sun Public License Notice
005:         *
006:         *  The contents of this file are subject to the Sun Public License Version
007:         *  1.0 (the "License"). You may not use this file except in compliance with
008:         *  the License. A copy of the License is available at http://www.sun.com/
009:         *  
010:         *  The Original Code is Java 3D(tm) Fly Through.
011:         *  The Initial Developer of the Original Code is Paul Byrne.
012:         *  Portions created by Paul Byrne are Copyright (C) 2002.
013:         *  All Rights Reserved.
014:         *  
015:         *  Contributor(s): Paul Byrne.
016:         *  
017:         **/
018:        package org.jdesktop.j3dfly.utils.gui;
019:
020:        import java.awt.Graphics;
021:        import java.awt.Dimension;
022:        import java.net.URL;
023:        import java.awt.Image;
024:        import java.awt.Toolkit;
025:        import java.awt.Color;
026:        import java.awt.MediaTracker;
027:        import java.awt.image.BufferedImage;
028:
029:        /**
030:         * A General purpose Splash Window for display while during
031:         * application startup.
032:         *
033:         * The window contains an image and can display text messages to mark
034:         * progress of application startup.
035:         *
036:         * @author  paulby
037:         * @version 
038:         */
039:        public class SplashWindow extends javax.swing.JWindow {
040:
041:            private static SplashWindow splashWindow = null;
042:            private SplashPanel panel = null;
043:
044:            /** Creates new SplashWindow
045:             * @param imageResourceName is the name of the image file to display on
046:             * the splash screen in the form of a Java Resource
047:             */
048:            public SplashWindow(final String imageResourceName) {
049:                initComponents();
050:
051:                URL imageURL = this .getClass().getClassLoader().getResource(
052:                        imageResourceName);
053:                Image image = Toolkit.getDefaultToolkit().createImage(imageURL);
054:
055:                Dimension screenDim = Toolkit.getDefaultToolkit()
056:                        .getScreenSize();
057:
058:                MediaTracker tracker = new MediaTracker(this );
059:                tracker.addImage(image, 1);
060:                try {
061:                    tracker.waitForAll();
062:                } catch (InterruptedException e) {
063:                }
064:
065:                panel = new SplashPanel(image);
066:                this .getContentPane().add("Center", panel);
067:                pack();
068:
069:                Dimension windowDim = getPreferredSize();
070:
071:                setLocation(screenDim.width / 2 - windowDim.width / 2,
072:                        screenDim.height / 2 - windowDim.height / 2);
073:            }
074:
075:            /** Creates and show a SplashWindow
076:             * @param imageResourceName is the name of the image file to display on
077:             * the splash screen in the form of a Java Resource
078:             */
079:            public static void showSplashscreen(final String imageResourceName) {
080:                if (splashWindow == null)
081:                    splashWindow = new SplashWindow(imageResourceName);
082:
083:                splashWindow.setVisible(true);
084:            }
085:
086:            /** 
087:             * Destroy any locally held resource and hide the window
088:             */
089:            public static void destroySplashscreen() {
090:                splashWindow.setVisible(false);
091:
092:                // Dispose call invokeAndWait which deadlocks when
093:                // using the editor to look at lg3d. Call dispose
094:                // from the swing eventqueue to overcome
095:                java.awt.EventQueue.invokeLater(new Runnable() {
096:                    public void run() {
097:                        splashWindow.dispose();
098:                        splashWindow = null;
099:                    }
100:                });
101:            }
102:
103:            /**
104:             * Show this message on the splash screen
105:             */
106:            public static void showMessage(final String message) {
107:                if (splashWindow != null)
108:                    splashWindow.actualShowMessage(message);
109:            }
110:
111:            protected void actualShowMessage(final String message) {
112:                panel.showMessage(message);
113:            }
114:
115:            /** This method is called from within the constructor to
116:             * initialize the form.
117:             * WARNING: Do NOT modify this code. The content of this method is
118:             * always regenerated by the FormEditor.
119:             */
120:            private void initComponents() {//GEN-BEGIN:initComponents
121:                addWindowListener(new java.awt.event.WindowAdapter() {
122:                    public void windowClosing(java.awt.event.WindowEvent evt) {
123:                        exitForm(evt);
124:                    }
125:                });
126:            }//GEN-END:initComponents
127:
128:            /** Exit the Application */
129:            private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
130:                System.exit(0);
131:            }//GEN-LAST:event_exitForm
132:
133:            // Variables declaration - do not modify//GEN-BEGIN:variables
134:            // End of variables declaration//GEN-END:variables
135:
136:            class SplashPanel extends javax.swing.JPanel {
137:                private BufferedImage image;
138:                private BufferedImage messageImage = null;
139:                private String message = "";
140:
141:                private int messageX = 40;
142:                private int messageY = 55;
143:                private int messageH = 20;
144:                private int messageW = 200;
145:                private int ascent;
146:
147:                public SplashPanel(final Image im) {
148:                    int width = im.getWidth(null);
149:                    int height = im.getHeight(null);
150:
151:                    image = new BufferedImage(width, height,
152:                            BufferedImage.TYPE_INT_RGB);
153:                    image.getGraphics().drawImage(im, 0, 0, null);
154:
155:                    Dimension d = new Dimension(width, height);
156:                    setPreferredSize(d);
157:                    setMinimumSize(d);
158:
159:                    ascent = getFontMetrics(getFont()).getMaxAscent();
160:                    messageH = getFontMetrics(getFont()).getMaxDescent()
161:                            + ascent;
162:                    messageW = width - messageX;
163:
164:                    messageImage = image.getSubimage(messageX, messageY
165:                            - ascent, messageW, messageH);
166:                }
167:
168:                public void showMessage(final String message) {
169:                    this .message = message;
170:                    Graphics g = getGraphics();
171:                    g
172:                            .drawImage(messageImage, messageX, messageY
173:                                    - ascent, null);
174:                    g.drawString(message, messageX, messageY);
175:                }
176:
177:                public void paint(Graphics g) {
178:                    g.drawImage(image, 0, 0, null);
179:
180:                    g.drawString(message, messageX, messageY);
181:                }
182:
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.