Source Code Cross Referenced for FrameLauncher.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.awt.*;
006:        import java.awt.event.*;
007:        import java.awt.image.*;
008:
009:        /**
010:         * <code>FrameLauncher</code> is a double buffered frame
011:         * to launch any <i>thinlet</i> component as an application
012:         */
013:        public class FrameLauncher extends Frame implements  WindowListener {
014:
015:            private transient Thinlet content;
016:            private transient Image doublebuffer;
017:
018:            /**
019:             * Construct and show a new frame with the specified title, including the
020:             * given <i>thinlet</i> component. The frame is centered on the screen, and its
021:             * preferred size is specified (excluding the frame's borders). The icon is
022:             * the thinlet logo
023:             * 
024:             * @param title the title to be displayed in the frame's border
025:             * @param content a <i>thinlet</i> instance
026:             * @param width the preferred width of the content
027:             * @param height the preferred height of the content
028:             */
029:            public FrameLauncher(String title, Thinlet content, int width,
030:                    int height) {
031:                super (title);
032:                this .content = content;
033:                add(content, BorderLayout.CENTER);
034:                addWindowListener(this );
035:                pack();
036:
037:                Insets is = getInsets();
038:                width += is.left + is.right;
039:                height += is.top + is.bottom;
040:                Dimension ss = getToolkit().getScreenSize();
041:                width = Math.min(width, ss.width);
042:                height = Math.min(height, ss.height);
043:                setBounds((ss.width - width) / 2, (ss.height - height) / 2,
044:                        width, height);
045:                setVisible(true);
046:                //maximize: setBounds(-is.left, -is.top, ss.width + is.left + is.right, ss.height + is.top + is.bottom);
047:
048:                int[] pix = new int[16 * 16];
049:                for (int x = 0; x < 16; x++) {
050:                    int sx = ((x >= 1) && (x <= 9)) ? 1
051:                            : (((x >= 11) && (x <= 14)) ? 2 : 0);
052:                    for (int y = 0; y < 16; y++) {
053:                        int sy = ((y >= 1) && (y <= 9)) ? 1
054:                                : (((y >= 11) && (y <= 14)) ? 2 : 0);
055:                        pix[y * 16 + x] = ((sx == 0) || (sy == 0)) ? 0xffffffff
056:                                : ((sx == 1) ? ((sy == 1) ? (((y == 2)
057:                                        && (x >= 2) && (x <= 8)) ? 0xffffffff
058:                                        : (((y >= 3) && (y <= 8)) ? ((x == 5) ? 0xffffffff
059:                                                : (((x == 4) || (x == 6)) ? 0xffe8bcbd
060:                                                        : 0xffb01416))
061:                                                : 0xffb01416))
062:                                        : 0xff377ca4)
063:                                        : ((sy == 1) ? 0xff3a831d : 0xfff2cc9c));
064:                    }
065:                }
066:                setIconImage(createImage(new MemoryImageSource(16, 16, pix, 0,
067:                        16)));
068:            }
069:
070:            /**
071:             * Call the paint method to redraw this component without painting a
072:             * background rectangle
073:             */
074:            public void update(Graphics g) {
075:                paint(g);
076:            }
077:
078:            /**
079:             * Create a double buffer if needed,
080:             * the <i>thinlet</i> component paints the content
081:             */
082:            public void paint(Graphics g) {
083:                if (doublebuffer == null) {
084:                    Dimension d = getSize();
085:                    doublebuffer = createImage(d.width, d.height);
086:                }
087:                Graphics dg = doublebuffer.getGraphics();
088:                dg.setClip(g.getClipBounds());
089:                super .paint(dg);
090:                dg.dispose();
091:                g.drawImage(doublebuffer, 0, 0, this );
092:            }
093:
094:            /**
095:             * Clear the double buffer image (because the frame has been resized),
096:             * the overriden method lays out its components
097:             * (centers the <i>thinlet</i> component)
098:             */
099:            public void doLayout() {
100:                if (doublebuffer != null) {
101:                    doublebuffer.flush();
102:                    doublebuffer = null;
103:                }
104:                super .doLayout();
105:            }
106:
107:            /**
108:             * Notify the <i>thinlet</i> component and terminates the Java Virtual Machine,
109:             * or redisplay the frame depending on the return value of <i>thinlet</i>'s
110:             * <code>destroy</code> method (true by default,
111:             * thus terminates the VM if not overriden)
112:             */
113:            public void windowClosing(WindowEvent e) {
114:                if (content.destroy()) {
115:                    System.exit(0);
116:                }
117:                setVisible(true);
118:            }
119:
120:            public void windowOpened(WindowEvent e) {
121:            }
122:
123:            public void windowClosed(WindowEvent e) {
124:            }
125:
126:            public void windowIconified(WindowEvent e) {
127:            }
128:
129:            public void windowDeiconified(WindowEvent e) {
130:            }
131:
132:            public void windowActivated(WindowEvent e) {
133:            }
134:
135:            public void windowDeactivated(WindowEvent e) {
136:            }
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.