Source Code Cross Referenced for SynthEditorPaneUI.java in  » 6.0-JDK-Core » swing » javax » swing » plaf » synth » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing.plaf.synth 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.swing.plaf.synth;
027
028        import java.awt.*;
029        import javax.swing.*;
030        import javax.swing.text.*;
031        import javax.swing.plaf.*;
032        import javax.swing.plaf.basic.BasicEditorPaneUI;
033        import java.beans.PropertyChangeEvent;
034        import sun.swing.plaf.synth.SynthUI;
035
036        /**
037         * Provides the look and feel for a JEditorPane in the
038         * Synth look and feel.
039         *
040         * @author  Shannon Hickey
041         * @version 1.16 05/05/07
042         */
043        class SynthEditorPaneUI extends BasicEditorPaneUI implements  SynthUI {
044            private SynthStyle style;
045            /* 
046             * I would prefer to use UIResource instad of this. 
047             * Unfortunately Boolean is a final class
048             */
049            private Boolean localTrue = new Boolean(true);
050            private Boolean localFalse = new Boolean(false);
051
052            /**
053             * Creates a UI for the JTextPane.
054             *
055             * @param c the JTextPane component
056             * @return the UI
057             */
058            public static ComponentUI createUI(JComponent c) {
059                return new SynthEditorPaneUI();
060            }
061
062            protected void installDefaults() {
063                // Installs the text cursor on the component
064                super .installDefaults();
065                JComponent c = getComponent();
066                Object clientProperty = c
067                        .getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES);
068                if (clientProperty == null || clientProperty == localFalse) {
069                    c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,
070                            localTrue);
071                }
072                updateStyle((JTextComponent) getComponent());
073            }
074
075            protected void uninstallDefaults() {
076                SynthContext context = getContext(getComponent(), ENABLED);
077                JComponent c = getComponent();
078                c.putClientProperty("caretAspectRatio", null);
079
080                style.uninstallDefaults(context);
081                context.dispose();
082                style = null;
083
084                Object clientProperty = c
085                        .getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES);
086                if (clientProperty == localTrue) {
087                    getComponent()
088                            .putClientProperty(
089                                    JEditorPane.HONOR_DISPLAY_PROPERTIES,
090                                    Boolean.FALSE);
091                }
092                super .uninstallDefaults();
093            }
094
095            /**
096             * This method gets called when a bound property is changed
097             * on the associated JTextComponent.  This is a hook
098             * which UI implementations may change to reflect how the
099             * UI displays bound properties of JTextComponent subclasses.
100             * This is implemented to rebuild the ActionMap based upon an
101             * EditorKit change.
102             *
103             * @param evt the property change event
104             */
105            protected void propertyChange(PropertyChangeEvent evt) {
106                if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
107                    updateStyle((JTextComponent) evt.getSource());
108                }
109                super .propertyChange(evt);
110            }
111
112            private void updateStyle(JTextComponent comp) {
113                SynthContext context = getContext(comp, ENABLED);
114                SynthStyle oldStyle = style;
115
116                style = SynthLookAndFeel.updateStyle(context, this );
117
118                if (style != oldStyle) {
119                    SynthTextFieldUI.updateStyle(comp, context,
120                            getPropertyPrefix());
121
122                    if (oldStyle != null) {
123                        uninstallKeyboardActions();
124                        installKeyboardActions();
125                    }
126                }
127                context.dispose();
128            }
129
130            public SynthContext getContext(JComponent c) {
131                return getContext(c, getComponentState(c));
132            }
133
134            private SynthContext getContext(JComponent c, int state) {
135                return SynthContext.getContext(SynthContext.class, c,
136                        SynthLookAndFeel.getRegion(c), style, state);
137            }
138
139            private int getComponentState(JComponent c) {
140                return SynthLookAndFeel.getComponentState(c);
141            }
142
143            public void update(Graphics g, JComponent c) {
144                SynthContext context = getContext(c);
145
146                SynthLookAndFeel.update(context, g);
147                paintBackground(context, g, c);
148                paint(context, g);
149                context.dispose();
150            }
151
152            protected void paint(SynthContext context, Graphics g) {
153                super .paint(g, getComponent());
154            }
155
156            protected void paintBackground(Graphics g) {
157                // Overriden to do nothing, all our painting is done from update/paint.
158            }
159
160            void paintBackground(SynthContext context, Graphics g, JComponent c) {
161                context.getPainter().paintEditorPaneBackground(context, g, 0,
162                        0, c.getWidth(), c.getHeight());
163            }
164
165            public void paintBorder(SynthContext context, Graphics g, int x,
166                    int y, int w, int h) {
167                context.getPainter().paintEditorPaneBorder(context, g, x, y, w,
168                        h);
169            }
170        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.