Source Code Cross Referenced for HtmlStatusPanel.java in  » Development » Houston » houston » 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 » Development » Houston » houston.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         ** Houston - Status and Logging Toolkit
003:         ** Copyright (c) 2001, 2002, 2003 by Gerald Bauer
004:         **
005:         ** This program is free software.
006:         **
007:         ** You may redistribute it and/or modify it under the terms of the GNU
008:         ** Lesser General Public License as published by the Free Software Foundation.
009:         ** Version 2.1 of the license should be included with this distribution in
010:         ** the file LICENSE, as well as License.html. If the license is not
011:         ** included with this distribution, you may find a copy at the FSF web
012:         ** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
013:         ** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
014:         **
015:         ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
016:         ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
017:         ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
018:         ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
019:         ** REDISTRIBUTION OF THIS SOFTWARE.
020:         **
021:         */
022:
023:        package houston.swing;
024:
025:        import java.awt.*;
026:        import java.awt.datatransfer.*;
027:        import java.awt.event.*;
028:        import java.io.*;
029:        import java.util.*;
030:        import javax.swing.*;
031:        import javax.swing.table.*;
032:        import javax.swing.text.*;
033:        import javax.swing.text.html.*;
034:        import houston.*;
035:
036:        public class HtmlStatusPanel extends JPanel implements  StatusListener {
037:            private final static String END_MARKER_ID = "201";
038:            static Logger T = Logger.getLogger(HtmlStatusPanel.class);
039:            private JEditorPane _browser;
040:
041:            private int _counter = 0;
042:            private JScrollPane _scrollPane;
043:
044:            public HtmlStatusPanel() {
045:                setLayout(new BorderLayout());
046:                setBorder(BorderFactory.createEtchedBorder());
047:
048:                _browser = new JEditorPane();
049:                _browser.setEditable(false);
050:                _browser.setContentType("text/html");
051:
052:                // note: clear sets up JEditorPane
053:                clear();
054:
055:                Status.addListener(this );
056:
057:                _scrollPane = new JScrollPane(_browser);
058:                add(_scrollPane, BorderLayout.CENTER);
059:            }
060:
061:            public void clear() {
062:                // todo: isn't setText supposed to be thread-safe?
063:
064:                SwingUtilities.invokeLater(new Runnable() {
065:                    public void run() {
066:                        String html = "<html><head></head><body><table border=0><tr><td><p id=\""
067:                                + END_MARKER_ID
068:                                + "\"></td></tr></table></body></html>";
069:                        _browser.setText(html);
070:                        T.debug("html=" + html);
071:
072:                        /*
073:                         *  HTMLDocument htmlDoc   = (HTMLDocument) _browser.getDocument();
074:                         *  htmlDoc.dump( System.out );
075:                         */
076:                    }
077:                });
078:            }
079:
080:            public void error(String msg) {
081:                Toolkit.getDefaultToolkit().beep();
082:                message("<font color=red>" + msg + "</font>");
083:                T.error(msg);
084:            }
085:
086:            public void fatal(String msg) {
087:                Toolkit.getDefaultToolkit().beep();
088:                message("<font color=red>" + msg + "</font>");
089:                T.fatal(msg);
090:            }
091:
092:            //
093:            // implementation of the StatusListener Interface
094:            //
095:
096:            public void hint(String msg) {
097:                message("<font color=grey>" + msg + "</font>");
098:                T.debug(msg);
099:            }
100:
101:            public void info(String msg) {
102:                message(msg);
103:                T.debug(msg);
104:            }
105:
106:            public void info(int level, String msg) {
107:                message(level, msg);
108:                T.debug(msg);
109:            }
110:
111:            public void warning(String msg) {
112:                message("<font color=#ff8429>" + msg + "</font>");
113:                T.warning(msg);
114:            }
115:
116:            private void insertHtml(final String html) {
117:                SwingUtilities.invokeLater(new Runnable() {
118:                    public void run() {
119:                        try {
120:                            HTMLDocument htmlDoc = (HTMLDocument) _browser
121:                                    .getDocument();
122:                            Element endMarker = htmlDoc
123:                                    .getElement(END_MARKER_ID);
124:                            if (endMarker == null) {
125:                                T.error("endMarker not found");
126:                            }
127:                            htmlDoc.insertBeforeEnd(endMarker, html);
128:                        } catch (Exception ioex) {
129:                            T.error("insertBeforeEnd failed: "
130:                                    + ioex.toString());
131:                        }
132:                    }
133:                });
134:            }
135:
136:            private void message(int level, String msg) {
137:                _counter++;
138:
139:                // String line = "<h" + level + ">" + msg + "</h" + level + ">";
140:                String line = "<b>" + msg + "</b><br>";
141:
142:                insertHtml(line);
143:            }
144:
145:            private void message(String msg) {
146:                _counter++;
147:
148:                // String line = msg;
149:                String line = msg + "<br>";
150:
151:                insertHtml(line);
152:            }
153:
154:        }
155:        // end of class
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.