Source Code Cross Referenced for AppletLauncher.java in  » Swing-Library » thinlet » thinlet » 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 » Swing Library » thinlet » thinlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Thinlet GUI toolkit - www.thinlet.com
002:         * Copyright (C) 2002-2003 Robert Bajzat (robert.bajzat@thinlet.com) */
003:        package thinlet;
004:
005:        import java.applet.*;
006:        import java.awt.*;
007:
008:        /**
009:         * <code>AppletLauncher</code> is a double buffered applet
010:         * to launch any <i>thinlet</i> component
011:         */
012:        public class AppletLauncher extends Applet implements  Runnable {
013:
014:            private transient Thinlet content;
015:            private transient Image doublebuffer;
016:
017:            /**
018:             * Applet instance is created by the browser or applet viewer
019:             */
020:            public AppletLauncher() {
021:                super (); // for javadoc
022:            }
023:
024:            /**
025:             * Called by the browser to inform this applet that it has been loaded into
026:             * the system, it displays the <i>Loading...</i> label and starts the loader thread
027:             */
028:            public void init() {
029:                setBackground(Color.white);
030:                setForeground(Color.darkGray);
031:                setLayout(new BorderLayout());
032:                add(new Label("Loading...", Label.CENTER), BorderLayout.CENTER);
033:                new Thread(this ).start();
034:            }
035:
036:            /**
037:             * Create a new <i>thinlet</i> instance of the class given as
038:             * <code>class</code> applet parameter, and show it or the
039:             * message of the thrown exception. First try a contructor with
040:             * an applet parameter (thus you get this applet instance e.g. for
041:             * the parameters of the applet HTML tag), then the empty constructor
042:             */
043:            public void run() {
044:                try {
045:                    Class thinletclass = Class.forName(getParameter("class"));
046:                    try {
047:                        content = (Thinlet) thinletclass.getConstructor(
048:                                new Class[] { Applet.class }).newInstance(
049:                                new Object[] { this  });
050:                    } catch (NoSuchMethodException nsme) {
051:                        content = (Thinlet) thinletclass.newInstance();
052:                    }
053:                    removeAll();
054:                    add(content, BorderLayout.CENTER);
055:                } catch (Throwable exc) {
056:                    removeAll();
057:                    add(new Label(exc.getClass().getName() + " "
058:                            + exc.getMessage(), Label.CENTER),
059:                            BorderLayout.CENTER);
060:                }
061:                doLayout();
062:                repaint();
063:            }
064:
065:            /**
066:             * Clear the double buffer image, the overriden method lays out its
067:             * components (centers the <i>thinlet</i> component)
068:             */
069:            public void doLayout() {
070:                super .doLayout();
071:                if (doublebuffer != null) {
072:                    doublebuffer.flush();
073:                    doublebuffer = null;
074:                }
075:            }
076:
077:            /**
078:             * Called by the browser to inform this applet that it should stop its execution,
079:             * it clears the double buffer image
080:             */
081:            public void stop() {
082:                if (doublebuffer != null) {
083:                    doublebuffer.flush();
084:                    doublebuffer = null;
085:                }
086:            }
087:
088:            /**
089:             * Call the paint method to redraw this component without painting a
090:             * background rectangle
091:             */
092:            public void update(Graphics g) {
093:                paint(g);
094:            }
095:
096:            /**
097:             * Create a double buffer if needed,
098:             * the <i>thinlet</i> component paints the content
099:             */
100:            public void paint(Graphics g) {
101:                if (doublebuffer == null) {
102:                    Dimension d = getSize();
103:                    doublebuffer = createImage(d.width, d.height);
104:                }
105:                Graphics dg = doublebuffer.getGraphics();
106:                dg.setClip(g.getClipBounds());
107:                super .paint(dg);
108:                dg.dispose();
109:                g.drawImage(doublebuffer, 0, 0, this );
110:            }
111:
112:            /**
113:             * Called by the browser to inform this applet that it is being reclaimed,
114:             * it calls the <i>thinlet</i> component's <code>destroy</code> method
115:             * (its return value is irrelevant)
116:             */
117:            public void destroy() {
118:                content.destroy();
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.