jdk/src/share/classes/javax/swing/JTextPane.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 410 4bc25999f850
child 3750 4195b035138f
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 410
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
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
package javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.ActionEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.text.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * A text component that can be marked up with attributes that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * represented graphically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * You can find how-to information and examples of using text panes in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/text.html">Using Text Components</a>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * a section in <em>The Java Tutorial.</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * This component models paragraphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * that are composed of runs of character level attributes.  Each
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * paragraph may have a logical style attached to it which contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * the default attributes to use if not overridden by attributes set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * on the paragraph or character run.  Components and images may
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * be embedded in the flow of text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <dl>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <dt><b><font size=+1>Newlines</font></b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <dd>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * For a discussion on how newlines are handled, see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <a href="text/DefaultEditorKit.html">DefaultEditorKit</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * </dl>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *   attribute: isContainer true
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * description: A text component that can be marked up with attributes that are graphically represented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * @author  Timothy Prinzing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * @see javax.swing.text.StyledEditorKit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
public class JTextPane extends JEditorPane {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Creates a new <code>JTextPane</code>.  A new instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * <code>StyledEditorKit</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * created and set, and the document model set to <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public JTextPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        EditorKit editorKit = createDefaultEditorKit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        String contentType = editorKit.getContentType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        if (contentType != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            && getEditorKitClassNameForContentType(contentType) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                 defaultEditorKitMap.get(contentType)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            setEditorKitForContentType(contentType, editorKit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        setEditorKit(editorKit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * Creates a new <code>JTextPane</code>, with a specified document model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * A new instance of <code>javax.swing.text.StyledEditorKit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *  is created and set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @param doc the document model
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public JTextPane(StyledDocument doc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        this();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        setStyledDocument(doc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Returns the class ID for the UI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @return the string "TextPaneUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        return uiClassID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Associates the editor with a text document.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * must be a <code>StyledDocument</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @param doc  the document to display/edit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @exception IllegalArgumentException  if <code>doc</code> can't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *   be narrowed to a <code>StyledDocument</code> which is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *   required type of model for this text component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public void setDocument(Document doc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        if (doc instanceof StyledDocument) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            super.setDocument(doc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            throw new IllegalArgumentException("Model must be StyledDocument");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Associates the editor with a text document.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * The currently registered factory is used to build a view for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * the document, which gets displayed by the editor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @param doc  the document to display/edit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public void setStyledDocument(StyledDocument doc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        super.setDocument(doc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Fetches the model associated with the editor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @return the model
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public StyledDocument getStyledDocument() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        return (StyledDocument) getDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * Replaces the currently selected content with new content
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * represented by the given string.  If there is no selection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * this amounts to an insert of the given text.  If there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * is no replacement text this amounts to a removal of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * current selection.  The replacement text will have the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * attributes currently defined for input at the point of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * insertion.  If the document is not editable, beep and return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @param content  the content to replace the selection with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public void replaceSelection(String content) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        replaceSelection(content, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    private void replaceSelection(String content, boolean checkEditable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if (checkEditable && !isEditable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            UIManager.getLookAndFeel().provideErrorFeedback(JTextPane.this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        Document doc = getStyledDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        if (doc != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                Caret caret = getCaret();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                int p0 = Math.min(caret.getDot(), caret.getMark());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                int p1 = Math.max(caret.getDot(), caret.getMark());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                AttributeSet attr = getInputAttributes().copyAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                if (doc instanceof AbstractDocument) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    ((AbstractDocument)doc).replace(p0, p1 - p0, content,attr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                    if (p0 != p1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                        doc.remove(p0, p1 - p0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    if (content != null && content.length() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                        doc.insertString(p0, content, attr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            } catch (BadLocationException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                UIManager.getLookAndFeel().provideErrorFeedback(JTextPane.this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        }
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
     * Inserts a component into the document as a replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * for the currently selected content.  If there is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * selection the component is effectively inserted at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * current position of the caret.  This is represented in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * the associated document as an attribute of one character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * of content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * The component given is the actual component used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * JTextPane.  Since components cannot be a child of more than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * one container, this method should not be used in situations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * where the model is shared by text components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * The component is placed relative to the text baseline
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * according to the value returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * <code>Component.getAlignmentY</code>.  For Swing components
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * this value can be conveniently set using the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * <code>JComponent.setAlignmentY</code>.  For example, setting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * a value of <code>0.75</code> will cause 75 percent of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * component to be above the baseline, and 25 percent of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * component to be below the baseline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @param c    the component to insert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public void insertComponent(Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        MutableAttributeSet inputAttributes = getInputAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        inputAttributes.removeAttributes(inputAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        StyleConstants.setComponent(inputAttributes, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        replaceSelection(" ", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        inputAttributes.removeAttributes(inputAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Inserts an icon into the document as a replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * for the currently selected content.  If there is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * selection the icon is effectively inserted at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * current position of the caret.  This is represented in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * the associated document as an attribute of one character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * of content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @param g    the icon to insert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @see Icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    public void insertIcon(Icon g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        MutableAttributeSet inputAttributes = getInputAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        inputAttributes.removeAttributes(inputAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        StyleConstants.setIcon(inputAttributes, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        replaceSelection(" ", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        inputAttributes.removeAttributes(inputAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * Adds a new style into the logical style hierarchy.  Style attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * resolve from bottom up so an attribute specified in a child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * will override an attribute specified in the parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @param nm   the name of the style (must be unique within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *   collection of named styles).  The name may be <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     *   if the style is unnamed, but the caller is responsible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *   for managing the reference returned as an unnamed style can't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     *   be fetched by name.  An unnamed style may be useful for things
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     *   like character attribute overrides such as found in a style
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *   run.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @param parent the parent style.  This may be <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     *   if unspecified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *   attributes need not be resolved in some other style.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @return the new <code>Style</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    public Style addStyle(String nm, Style parent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        StyledDocument doc = getStyledDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return doc.addStyle(nm, parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Removes a named non-<code>null</code> style previously added to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * the document.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @param nm  the name of the style to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    public void removeStyle(String nm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        StyledDocument doc = getStyledDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        doc.removeStyle(nm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Fetches a named non-<code>null</code> style previously added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @param nm  the name of the style
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @return the <code>Style</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    public Style getStyle(String nm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        StyledDocument doc = getStyledDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        return doc.getStyle(nm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Sets the logical style to use for the paragraph at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * current caret position.  If attributes aren't explicitly set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * for character and paragraph attributes they will resolve
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * through the logical style assigned to the paragraph, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * in term may resolve through some hierarchy completely
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * independent of the element hierarchy in the document.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @param s  the logical style to assign to the paragraph,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     *          or <code>null</code> for no style
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public void setLogicalStyle(Style s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        StyledDocument doc = getStyledDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        doc.setLogicalStyle(getCaretPosition(), s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * Fetches the logical style assigned to the paragraph represented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * by the current position of the caret, or <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * @return the <code>Style</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    public Style getLogicalStyle() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        StyledDocument doc = getStyledDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        return doc.getLogicalStyle(getCaretPosition());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * Fetches the character attributes in effect at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * current location of the caret, or <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * @return the attributes, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    public AttributeSet getCharacterAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        StyledDocument doc = getStyledDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        Element run = doc.getCharacterElement(getCaretPosition());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        if (run != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            return run.getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * Applies the given attributes to character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * content.  If there is a selection, the attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * are applied to the selection range.  If there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * is no selection, the attributes are applied to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * the input attribute set which defines the attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * for any new text that gets inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @param attr the attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * @param replace if true, then replace the existing attributes first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    public void setCharacterAttributes(AttributeSet attr, boolean replace) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        int p0 = getSelectionStart();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        int p1 = getSelectionEnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        if (p0 != p1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            StyledDocument doc = getStyledDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            doc.setCharacterAttributes(p0, p1 - p0, attr, replace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            MutableAttributeSet inputAttributes = getInputAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            if (replace) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                inputAttributes.removeAttributes(inputAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            inputAttributes.addAttributes(attr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * Fetches the current paragraph attributes in effect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * at the location of the caret, or <code>null</code> if none.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @return the attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    public AttributeSet getParagraphAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        StyledDocument doc = getStyledDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        Element paragraph = doc.getParagraphElement(getCaretPosition());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        if (paragraph != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            return paragraph.getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * Applies the given attributes to paragraphs.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * there is a selection, the attributes are applied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * to the paragraphs that intersect the selection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * If there is no selection, the attributes are applied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * to the paragraph at the current caret position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * @param attr the non-<code>null</code> attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * @param replace if true, replace the existing attributes first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    public void setParagraphAttributes(AttributeSet attr, boolean replace) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        int p0 = getSelectionStart();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        int p1 = getSelectionEnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        StyledDocument doc = getStyledDocument();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        doc.setParagraphAttributes(p0, p1 - p0, attr, replace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * Gets the input attributes for the pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @return the attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    public MutableAttributeSet getInputAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        return getStyledEditorKit().getInputAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * Gets the editor kit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @return the editor kit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    protected final StyledEditorKit getStyledEditorKit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        return (StyledEditorKit) getEditorKit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * @see #getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @see #readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    private static final String uiClassID = "TextPaneUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * See <code>readObject</code> and <code>writeObject</code> in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * <code>JComponent</code> for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * information about serialization in Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @param s the output stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        if (getUIClassID().equals(uiClassID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            byte count = JComponent.getWriteObjCounter(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            JComponent.setWriteObjCounter(this, --count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            if (count == 0 && ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    // --- JEditorPane ------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * Creates the <code>EditorKit</code> to use by default.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * is implemented to return <code>javax.swing.text.StyledEditorKit</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @return the editor kit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    protected EditorKit createDefaultEditorKit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        return new StyledEditorKit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * Sets the currently installed kit for handling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * content.  This is the bound property that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * establishes the content type of the editor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * @param kit the desired editor behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * @exception IllegalArgumentException if kit is not a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     *          <code>StyledEditorKit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    public final void setEditorKit(EditorKit kit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        if (kit instanceof StyledEditorKit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            super.setEditorKit(kit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            throw new IllegalArgumentException("Must be StyledEditorKit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * Returns a string representation of this <code>JTextPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * @return  a string representation of this <code>JTextPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        return super.paramString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
}