Source Code Cross Referenced for CustomTextPaneUI.java in  » Database-Client » executequery » org » underworldlabs » swing » plaf » base » 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 » Database Client » executequery » org.underworldlabs.swing.plaf.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.underworldlabs.swing.plaf.base;
002:
003:        import java.awt.Rectangle;
004:        import java.awt.Shape;
005:
006:        import javax.swing.JComponent;
007:        import javax.swing.UIManager;
008:        import javax.swing.plaf.ComponentUI;
009:        import javax.swing.plaf.basic.BasicTextPaneUI;
010:        import javax.swing.text.AbstractDocument;
011:        import javax.swing.text.BadLocationException;
012:        import javax.swing.text.DefaultHighlighter;
013:        import javax.swing.text.Document;
014:        import javax.swing.text.Highlighter;
015:        import javax.swing.text.JTextComponent;
016:        import javax.swing.text.Position;
017:        import javax.swing.text.View;
018:
019:        /*
020:         * CustomTextPaneUI.java
021:         *
022:         * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
023:         *
024:         * This program is free software; you can redistribute it and/or
025:         * modify it under the terms of the GNU General Public License
026:         * as published by the Free Software Foundation; either version 2
027:         * of the License, or any later version.
028:         *
029:         * This program is distributed in the hope that it will be useful,
030:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
031:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
032:         * GNU General Public License for more details.
033:         *
034:         * You should have received a copy of the GNU General Public License
035:         * along with this program; if not, write to the Free Software
036:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
037:         *
038:         */
039:
040:        /**
041:         * An alternative UI delegate for JTextArea that paints the
042:         * selection highlight correctly.  For example, when a selection
043:         * starts on one line and ends on the next, the highlight on the
044:         * first line will extend all the way to the right margin.
045:         *
046:         * @author Alan Moore
047:         */
048:        /**
049:         *
050:         * @author   Takis Diakoumis
051:         * @version  $Revision: 1.4 $
052:         * @date     $Date: 2006/05/14 06:56:07 $
053:         */
054:        public class CustomTextPaneUI extends BasicTextPaneUI {
055:            /**
056:             * Informs the UIManager that this class should be used as the UI
057:             * delegate for JTextArea's.  This method should be called during
058:             * app initialization, before any components are created.
059:             */
060:            public static void initialize() {
061:                String key = "TextPaneUI";
062:                Class cls = CustomTextPaneUI.class;
063:                String name = cls.getName();
064:                UIManager.put(key, name);
065:                UIManager.put(name, cls);
066:            }
067:
068:            /**
069:             * Creates a UI for a JTextPane.
070:             *
071:             * @param c a text area
072:             * @return a CustomTextAreaUI instance
073:             */
074:            public static ComponentUI createUI(JComponent c) {
075:                return new CustomTextPaneUI();
076:            }
077:
078:            /**
079:             * Creates the object to use for adding highlights.  This will
080:             * be a non-layered version of DefaultHighlighter, so that
081:             * multi-line selections will be painted properly.
082:             *
083:             * @return the highlighter
084:             */
085:            protected Highlighter createHighlighter() {
086:                DefaultHighlighter h = new DefaultHighlighter();
087:                h.setDrawsLayeredHighlights(false);
088:                return h;
089:            }
090:
091:            /**
092:             * Causes the portion of the view responsible for the given part
093:             * of the model to be repainted. This is overridden to repaint the
094:             * whole width of the textarea, so that selection highlighting will
095:             * be rendered properly.
096:             *
097:             * @param p0 the beginning of the range >= 0
098:             * @param p1 the end of the range >= p0
099:             */
100:            public void damageRange(JTextComponent t, int p0, int p1,
101:                    Position.Bias p0Bias, Position.Bias p1Bias) {
102:                View rv = getRootView(t);
103:                Rectangle alloc = getVisibleEditorRect();
104:                Document doc = t.getDocument();
105:                if (rv != null && alloc != null && doc != null) {
106:                    if (doc instanceof  AbstractDocument) {
107:                        ((AbstractDocument) doc).readLock();
108:                    }
109:                    try {
110:                        rv.setSize(alloc.width, alloc.height);
111:                        Shape toDamage = rv.modelToView(p0, p0Bias, p1, p1Bias,
112:                                alloc);
113:                        Rectangle rect = (toDamage instanceof  Rectangle) ? (Rectangle) toDamage
114:                                : toDamage.getBounds();
115:                        t.repaint(alloc.x, rect.y, alloc.width, rect.height);
116:                    } catch (BadLocationException ex) {
117:                    } finally {
118:                        if (doc instanceof  AbstractDocument) {
119:                            ((AbstractDocument) doc).readUnlock();
120:                        }
121:                    }
122:                }
123:            }
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.