jdk/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 1290 da8902cd496c
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.synth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.text.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.plaf.basic.BasicTextFieldUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.event.FocusEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.event.FocusListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.swing.plaf.synth.SynthUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Basis of a look and feel for a JTextField in the Synth
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @author  Shannon Hickey
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
class SynthTextFieldUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    extends BasicTextFieldUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    implements SynthUI, FocusListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private SynthStyle style;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Creates a UI for a JTextField.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param c the text field
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @return the UI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public static ComponentUI createUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        return new SynthTextFieldUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public SynthTextFieldUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private void updateStyle(JTextComponent comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        SynthContext context = getContext(comp, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        SynthStyle oldStyle = style;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        style = SynthLookAndFeel.updateStyle(context, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        if (style != oldStyle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            SynthTextFieldUI.updateStyle(comp, context, getPropertyPrefix());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            if (oldStyle != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                uninstallKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                installKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    static void updateStyle(JTextComponent comp, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            String prefix) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        SynthStyle style = context.getStyle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        Color color = comp.getCaretColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        if (color == null || color instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            comp.setCaretColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                (Color)style.get(context, prefix + ".caretForeground"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        Color fg = comp.getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if (fg == null || fg instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            fg = style.getColorForState(context, ColorType.TEXT_FOREGROUND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            if (fg != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                comp.setForeground(fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        Object ar = style.get(context, prefix + ".caretAspectRatio");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        if (ar instanceof Number) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            comp.putClientProperty("caretAspectRatio", ar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        context.setComponentState(SELECTED | FOCUSED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        Color s = comp.getSelectionColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        if (s == null || s instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            comp.setSelectionColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                style.getColor(context, ColorType.TEXT_BACKGROUND));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        Color sfg = comp.getSelectedTextColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (sfg == null || sfg instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            comp.setSelectedTextColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                style.getColor(context, ColorType.TEXT_FOREGROUND));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        context.setComponentState(DISABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        Color dfg = comp.getDisabledTextColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (dfg == null || dfg instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            comp.setDisabledTextColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                style.getColor(context, ColorType.TEXT_FOREGROUND));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        Insets margin = comp.getMargin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        if (margin == null || margin instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            margin = (Insets)style.get(context, prefix + ".margin");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            if (margin == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                // Some places assume margins are non-null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                margin = SynthLookAndFeel.EMPTY_UIRESOURCE_INSETS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            comp.setMargin(margin);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        Caret caret = comp.getCaret();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        if (caret instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            Object o = style.get(context, prefix + ".caretBlinkRate");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            if (o != null && o instanceof Integer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                Integer rate = (Integer)o;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                caret.setBlinkRate(rate.intValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public SynthContext getContext(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        return getContext(c, getComponentState(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    private SynthContext getContext(JComponent c, int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        return SynthContext.getContext(SynthContext.class, c,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                    SynthLookAndFeel.getRegion(c), style, state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    private int getComponentState(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        return SynthLookAndFeel.getComponentState(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public void update(Graphics g, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        SynthLookAndFeel.update(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        paintBackground(context, g, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        paint(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Paints the interface.  This is routed to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * paintSafely method under the guarantee that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * the model won't change from the view of this thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * while it's rendering (if the associated model is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * derived from AbstractDocument).  This enables the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * model to potentially be updated asynchronously.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    protected void paint(SynthContext context, Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        super.paint(g, getComponent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    void paintBackground(SynthContext context, Graphics g, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        context.getPainter().paintTextFieldBackground(context, g, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                                                c.getWidth(), c.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public void paintBorder(SynthContext context, Graphics g, int x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                            int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        context.getPainter().paintTextFieldBorder(context, g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    protected void paintBackground(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        // Overriden to do nothing, all our painting is done from update/paint.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * This method gets called when a bound property is changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * on the associated JTextComponent.  This is a hook
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * which UI implementations may change to reflect how the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * UI displays bound properties of JTextComponent subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * This is implemented to do nothing (i.e. the response to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * properties in JTextComponent itself are handled prior
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * to calling this method).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @param evt the property change event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    protected void propertyChange(PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            updateStyle((JTextComponent)evt.getSource());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        super.propertyChange(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public void focusGained(FocusEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        getComponent().repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    public void focusLost(FocusEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        getComponent().repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    protected void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        // Installs the text cursor on the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        super.installDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        updateStyle((JTextComponent)getComponent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        getComponent().addFocusListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    protected void uninstallDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        SynthContext context = getContext(getComponent(), ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        getComponent().putClientProperty("caretAspectRatio", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        getComponent().removeFocusListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        style.uninstallDefaults(context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        style = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        super.uninstallDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public void installUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        super.installUI(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
}