jdk/src/share/classes/java/awt/TextArea.java
author yan
Tue, 24 Jun 2014 16:57:02 +0400
changeset 25162 c388078278d4
parent 24865 09b1d992ca72
permissions -rw-r--r--
8043967: Fix doclint warnings for java.awt Reviewed-by: pchelko Contributed-by: Alexander Stepanov <alexander.v.stepanov@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
     2
 * Copyright (c) 1995, 2014, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1964
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1964
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1964
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1964
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1964
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.event.InputEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.KeyEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.peer.TextAreaPeer;
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
import java.util.HashSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * A <code>TextArea</code> object is a multi-line region
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * that displays text. It can be set to allow editing or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * to be read-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * The following image shows the appearance of a text area:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <img src="doc-files/TextArea-1.gif" alt="A TextArea showing the word 'Hello!'"
20451
4cedf4e1560a 8025409: Fix javadoc comments errors and warning reported by doclint report
cl
parents: 15318
diff changeset
    45
 * style="float:center; margin: 7px 10px;">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * This text area could be created by the following line of code:
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20451
diff changeset
    48
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <hr><blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * new TextArea("Hello", 5, 40);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * </pre></blockquote><hr>
23717
6457189cd574 8039259: Tidy warnings cleanup for java.awt
yan
parents: 23010
diff changeset
    52
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @author      Sami Shaio
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
    54
 * @since       1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public class TextArea extends TextComponent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * The number of rows in the <code>TextArea</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * This parameter will determine the text area's height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * Guaranteed to be non-negative.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @see #getRows()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @see #setRows(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    int rows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * The number of columns in the <code>TextArea</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * A column is an approximate average character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * width that is platform-dependent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * This parameter will determine the text area's width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Guaranteed to be non-negative.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @see  #setColumns(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @see  #getColumns()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    int columns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private static final String base = "text";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private static int nameCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * Create and display both vertical and horizontal scrollbars.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
    87
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public static final int SCROLLBARS_BOTH = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Create and display vertical scrollbar only.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
    93
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public static final int SCROLLBARS_VERTICAL_ONLY = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Create and display horizontal scrollbar only.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
    99
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public static final int SCROLLBARS_HORIZONTAL_ONLY = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Do not create or display any scrollbars for the text area.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   105
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public static final int SCROLLBARS_NONE = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Determines which scrollbars are created for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * text area. It can be one of four values :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * <code>SCROLLBARS_BOTH</code> = both scrollbars.<BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * <code>SCROLLBARS_HORIZONTAL_ONLY</code> = Horizontal bar only.<BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * <code>SCROLLBARS_VERTICAL_ONLY</code> = Vertical bar only.<BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * <code>SCROLLBARS_NONE</code> = No scrollbars.<BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @see #getScrollbarVisibility()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    private int scrollbarVisibility;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Cache the Sets of forward and backward traversal keys so we need not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * look them up each time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 5506
diff changeset
   126
    private static Set<AWTKeyStroke> forwardTraversalKeys, backwardTraversalKeys;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     private static final long serialVersionUID = 3692302836626095722L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Initialize JNI field and method ids
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        Toolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        forwardTraversalKeys = KeyboardFocusManager.initFocusTraversalKeysSet(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            "ctrl TAB",
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 5506
diff changeset
   146
            new HashSet<AWTKeyStroke>());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        backwardTraversalKeys = KeyboardFocusManager.initFocusTraversalKeysSet(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            "ctrl shift TAB",
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 5506
diff changeset
   149
            new HashSet<AWTKeyStroke>());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * Constructs a new text area with the empty string as text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * This text area is created with scrollbar visibility equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * {@link #SCROLLBARS_BOTH}, so both vertical and horizontal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * scrollbars will be visible for this text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *    <code>GraphicsEnvironment.isHeadless</code> returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @see java.awt.GraphicsEnvironment#isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public TextArea() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        this("", 0, 0, SCROLLBARS_BOTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Constructs a new text area with the specified text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * This text area is created with scrollbar visibility equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * {@link #SCROLLBARS_BOTH}, so both vertical and horizontal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * scrollbars will be visible for this text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @param      text       the text to be displayed; if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *             <code>text</code> is <code>null</code>, the empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *             string <code>""</code> will be displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *        <code>GraphicsEnvironment.isHeadless</code> returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @see java.awt.GraphicsEnvironment#isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public TextArea(String text) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        this(text, 0, 0, SCROLLBARS_BOTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * Constructs a new text area with the specified number of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * rows and columns and the empty string as text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * A column is an approximate average character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * width that is platform-dependent.  The text area is created with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * scrollbar visibility equal to {@link #SCROLLBARS_BOTH}, so both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * vertical and horizontal scrollbars will be visible for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @param rows the number of rows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @param columns the number of columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *     <code>GraphicsEnvironment.isHeadless</code> returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @see java.awt.GraphicsEnvironment#isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public TextArea(int rows, int columns) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        this("", rows, columns, SCROLLBARS_BOTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * Constructs a new text area with the specified text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * and with the specified number of rows and columns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * A column is an approximate average character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * width that is platform-dependent.  The text area is created with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * scrollbar visibility equal to {@link #SCROLLBARS_BOTH}, so both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * vertical and horizontal scrollbars will be visible for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @param      text       the text to be displayed; if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *             <code>text</code> is <code>null</code>, the empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *             string <code>""</code> will be displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @param     rows      the number of rows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @param     columns   the number of columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *   <code>GraphicsEnvironment.isHeadless</code> returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @see java.awt.GraphicsEnvironment#isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public TextArea(String text, int rows, int columns)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        this(text, rows, columns, SCROLLBARS_BOTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Constructs a new text area with the specified text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * and with the rows, columns, and scroll bar visibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * as specified.  All <code>TextArea</code> constructors defer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * this one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * The <code>TextArea</code> class defines several constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * that can be supplied as values for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * <code>scrollbars</code> argument:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * <li><code>SCROLLBARS_BOTH</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * <li><code>SCROLLBARS_VERTICAL_ONLY</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * <li><code>SCROLLBARS_HORIZONTAL_ONLY</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * <li><code>SCROLLBARS_NONE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * Any other value for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * <code>scrollbars</code> argument is invalid and will result in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * this text area being created with scrollbar visibility equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * the default value of {@link #SCROLLBARS_BOTH}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @param      text       the text to be displayed; if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     *             <code>text</code> is <code>null</code>, the empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *             string <code>""</code> will be displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @param      rows       the number of rows; if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     *             <code>rows</code> is less than <code>0</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *             <code>rows</code> is set to <code>0</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @param      columns    the number of columns; if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *             <code>columns</code> is less than <code>0</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     *             <code>columns</code> is set to <code>0</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * @param      scrollbars  a constant that determines what
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *             scrollbars are created to view the text area
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   251
     * @since      1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *    <code>GraphicsEnvironment.isHeadless</code> returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @see java.awt.GraphicsEnvironment#isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    public TextArea(String text, int rows, int columns, int scrollbars)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        super(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        this.rows = (rows >= 0) ? rows : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        this.columns = (columns >= 0) ? columns : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        if (scrollbars >= SCROLLBARS_BOTH && scrollbars <= SCROLLBARS_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            this.scrollbarVisibility = scrollbars;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            this.scrollbarVisibility = SCROLLBARS_BOTH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                              forwardTraversalKeys);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                              backwardTraversalKeys);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * Construct a name for this component.  Called by <code>getName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * when the name is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    String constructComponentName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        synchronized (TextArea.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            return base + nameCounter++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * Creates the <code>TextArea</code>'s peer.  The peer allows us to modify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * the appearance of the <code>TextArea</code> without changing any of its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            if (peer == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                peer = getToolkit().createTextArea(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * Inserts the specified text at the specified position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * in this text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * <p>Note that passing <code>null</code> or inconsistent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * parameters is invalid and will result in unspecified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * @param      str the non-<code>null</code> text to insert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @param      pos the position at which to insert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @see        java.awt.TextComponent#setText
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @see        java.awt.TextArea#replaceRange
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @see        java.awt.TextArea#append
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   310
     * @since      1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public void insert(String str, int pos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        insertText(str, pos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   317
     * Inserts the specified text at the specified position
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   318
     * in this text area.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   319
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   320
     * @param  str the non-{@code null} text to insert
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   321
     * @param  pos the position at which to insert
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * replaced by <code>insert(String, int)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    public synchronized void insertText(String str, int pos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        TextAreaPeer peer = (TextAreaPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        if (peer != null) {
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 2
diff changeset
   329
            peer.insert(str, pos);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            text = text.substring(0, pos) + str + text.substring(pos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * Appends the given text to the text area's current text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * <p>Note that passing <code>null</code> or inconsistent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * parameters is invalid and will result in unspecified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * @param     str the non-<code>null</code> text to append
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * @see       java.awt.TextArea#insert
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   343
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    public void append(String str) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        appendText(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   350
     * Appends the given text to the text area's current text.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   351
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   352
     * @param  str the text to append
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * replaced by <code>append(String)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    public synchronized void appendText(String str) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            insertText(str, getText().length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            text = text + str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * Replaces text between the indicated start and end positions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * with the specified replacement text.  The text at the end
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * position will not be replaced.  The text at the start
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * position will be replaced (unless the start position is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * same as the end position).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * The text position is zero-based.  The inserted substring may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * of a different length than the text it replaces.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * <p>Note that passing <code>null</code> or inconsistent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * parameters is invalid and will result in unspecified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * @param     str      the non-<code>null</code> text to use as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     *                     the replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * @param     start    the start position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * @param     end      the end position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * @see       java.awt.TextArea#insert
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   382
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    public void replaceRange(String str, int start, int end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        replaceText(str, start, end);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   389
     * Replaces a range of characters between
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   390
     * the indicated start and end positions
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   391
     * with the specified replacement text (the text at the end
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   392
     * position will not be replaced).
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   393
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   394
     * @param  str the non-{@code null} text to use as
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   395
     *         the replacement
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   396
     * @param  start the start position
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   397
     * @param  end the end position
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * replaced by <code>replaceRange(String, int, int)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    public synchronized void replaceText(String str, int start, int end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        TextAreaPeer peer = (TextAreaPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        if (peer != null) {
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 2
diff changeset
   405
            peer.replaceRange(str, start, end);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            text = text.substring(0, start) + str + text.substring(end);
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * Returns the number of rows in the text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @return    the number of rows in the text area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @see       #setRows(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @see       #getColumns()
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   416
     * @since     1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    public int getRows() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        return rows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * Sets the number of rows for this text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * @param       rows   the number of rows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * @see         #getRows()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * @see         #setColumns(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * @exception   IllegalArgumentException   if the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *                 supplied for <code>rows</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *                 is less than <code>0</code>
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   430
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    public void setRows(int rows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        int oldVal = this.rows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        if (rows < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            throw new IllegalArgumentException("rows less than zero.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        if (rows != oldVal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            this.rows = rows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            invalidate();
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
     * Returns the number of columns in this text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @return    the number of columns in the text area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @see       #setColumns(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @see       #getRows()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    public int getColumns() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        return columns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * Sets the number of columns for this text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * @param       columns   the number of columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @see         #getColumns()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * @see         #setRows(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * @exception   IllegalArgumentException   if the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     *                 supplied for <code>columns</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *                 is less than <code>0</code>
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   461
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    public void setColumns(int columns) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        int oldVal = this.columns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        if (columns < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            throw new IllegalArgumentException("columns less than zero.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        if (columns != oldVal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            this.columns = columns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            invalidate();
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 an enumerated value that indicates which scroll bars
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * the text area uses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * The <code>TextArea</code> class defines four integer constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * that are used to specify which scroll bars are available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * <code>TextArea</code> has one constructor that gives the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * application discretion over scroll bars.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @return     an integer that indicates which scroll bars are used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * @see        java.awt.TextArea#SCROLLBARS_BOTH
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * @see        java.awt.TextArea#SCROLLBARS_VERTICAL_ONLY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @see        java.awt.TextArea#SCROLLBARS_HORIZONTAL_ONLY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @see        java.awt.TextArea#SCROLLBARS_NONE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @see        java.awt.TextArea#TextArea(java.lang.String, int, int, int)
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   489
     * @since      1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    public int getScrollbarVisibility() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        return scrollbarVisibility;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * Determines the preferred size of a text area with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * number of rows and columns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @param     rows   the number of rows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @param     columns   the number of columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @return    the preferred dimensions required to display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     *                       the text area with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *                       number of rows and columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @see       java.awt.Component#getPreferredSize
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   505
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    public Dimension getPreferredSize(int rows, int columns) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        return preferredSize(rows, columns);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   512
     * Determines the preferred size of the text area with the specified
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   513
     * number of rows and columns.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   514
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   515
     * @param  rows the number of rows
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   516
     * @param  columns the number of columns
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   517
     * @return the preferred dimensions needed for the text area
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * replaced by <code>getPreferredSize(int, int)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    public Dimension preferredSize(int rows, int columns) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            TextAreaPeer peer = (TextAreaPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            return (peer != null) ?
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 2
diff changeset
   526
                       peer.getPreferredSize(rows, columns) :
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                       super.preferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * Determines the preferred size of this text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @return    the preferred dimensions needed for this text area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @see       java.awt.Component#getPreferredSize
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   535
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    public Dimension getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        return preferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * replaced by <code>getPreferredSize()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    public Dimension preferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            return ((rows > 0) && (columns > 0)) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                        preferredSize(rows, columns) :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                        super.preferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * Determines the minimum size of a text area with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * number of rows and columns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @param     rows   the number of rows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * @param     columns   the number of columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * @return    the minimum dimensions required to display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     *                       the text area with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     *                       number of rows and columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * @see       java.awt.Component#getMinimumSize
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   563
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    public Dimension getMinimumSize(int rows, int columns) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        return minimumSize(rows, columns);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   570
     * Determines the minimum size of the text area with the specified
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   571
     * number of rows and columns.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   572
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   573
     * @param  rows the number of rows
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   574
     * @param  columns the number of columns
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   575
     * @return the minimum size for the text area
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * replaced by <code>getMinimumSize(int, int)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    public Dimension minimumSize(int rows, int columns) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
            TextAreaPeer peer = (TextAreaPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            return (peer != null) ?
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 2
diff changeset
   584
                       peer.getMinimumSize(rows, columns) :
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                       super.minimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * Determines the minimum size of this text area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * @return    the preferred dimensions needed for this text area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * @see       java.awt.Component#getPreferredSize
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
   593
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    public Dimension getMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        return minimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * replaced by <code>getMinimumSize()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    public Dimension minimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
            return ((rows > 0) && (columns > 0)) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                        minimumSize(rows, columns) :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                        super.minimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * Returns a string representing the state of this <code>TextArea</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * This method is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * implementations. The returned string may be empty but may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * @return      the parameter string of this text area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        String sbVisStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        switch (scrollbarVisibility) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            case SCROLLBARS_BOTH:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                sbVisStr = "both";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            case SCROLLBARS_VERTICAL_ONLY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                sbVisStr = "vertical-only";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            case SCROLLBARS_HORIZONTAL_ONLY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                sbVisStr = "horizontal-only";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            case SCROLLBARS_NONE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                sbVisStr = "none";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                sbVisStr = "invalid display policy";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        return super.paramString() + ",rows=" + rows +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            ",columns=" + columns +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
          ",scrollbarVisibility=" + sbVisStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * Serialization support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * The textArea Serialized Data Version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    private int textAreaSerializedDataVersion = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * Read the ObjectInputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * <code>GraphicsEnvironment.isHeadless()</code> returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
      throws ClassNotFoundException, IOException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        // HeadlessException will be thrown by TextComponent's readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        // Make sure the state we just read in for columns, rows,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        // and scrollbarVisibility has legal values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        if (columns < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            columns = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        if (rows < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            rows = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        if ((scrollbarVisibility < SCROLLBARS_BOTH) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            (scrollbarVisibility > SCROLLBARS_NONE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            this.scrollbarVisibility = SCROLLBARS_BOTH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        if (textAreaSerializedDataVersion < 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                                  forwardTraversalKeys);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                                  backwardTraversalKeys);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * Returns the <code>AccessibleContext</code> associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * this <code>TextArea</code>. For text areas, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * <code>AccessibleContext</code> takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * <code>AccessibleAWTTextArea</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * A new <code>AccessibleAWTTextArea</code> instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * @return an <code>AccessibleAWTTextArea</code> that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     *         <code>AccessibleContext</code> of this <code>TextArea</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            accessibleContext = new AccessibleAWTTextArea();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * <code>TextArea</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * Java Accessibility API appropriate to text area user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    protected class AccessibleAWTTextArea extends AccessibleAWTTextComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
         * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        private static final long serialVersionUID = 3472827823632144419L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
         * Gets the state set of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
         * @return an instance of AccessibleStateSet describing the states
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
         * of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
         * @see AccessibleStateSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            states.add(AccessibleState.MULTI_LINE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
}