< prev index next >

src/java.desktop/share/classes/java/awt/TextArea.java

Print this page

        

*** 33,43 **** import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleState; import javax.accessibility.AccessibleStateSet; /** ! * A <code>TextArea</code> object is a multi-line region * that displays text. It can be set to allow editing or * to be read-only. * <p> * The following image shows the appearance of a text area: * <p> --- 33,43 ---- import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleState; import javax.accessibility.AccessibleStateSet; /** ! * A {@code TextArea} object is a multi-line region * that displays text. It can be set to allow editing or * to be read-only. * <p> * The following image shows the appearance of a text area: * <p>
*** 54,75 **** * @since 1.0 */ public class TextArea extends TextComponent { /** ! * The number of rows in the <code>TextArea</code>. * This parameter will determine the text area's height. * Guaranteed to be non-negative. * * @serial * @see #getRows() * @see #setRows(int) */ int rows; /** ! * The number of columns in the <code>TextArea</code>. * A column is an approximate average character * width that is platform-dependent. * This parameter will determine the text area's width. * Guaranteed to be non-negative. * --- 54,75 ---- * @since 1.0 */ public class TextArea extends TextComponent { /** ! * The number of rows in the {@code TextArea}. * This parameter will determine the text area's height. * Guaranteed to be non-negative. * * @serial * @see #getRows() * @see #setRows(int) */ int rows; /** ! * The number of columns in the {@code TextArea}. * A column is an approximate average character * width that is platform-dependent. * This parameter will determine the text area's width. * Guaranteed to be non-negative. *
*** 107,120 **** public static final int SCROLLBARS_NONE = 3; /** * Determines which scrollbars are created for the * text area. It can be one of four values : ! * <code>SCROLLBARS_BOTH</code> = both scrollbars.<BR> ! * <code>SCROLLBARS_HORIZONTAL_ONLY</code> = Horizontal bar only.<BR> ! * <code>SCROLLBARS_VERTICAL_ONLY</code> = Vertical bar only.<BR> ! * <code>SCROLLBARS_NONE</code> = No scrollbars.<BR> * * @serial * @see #getScrollbarVisibility() */ private int scrollbarVisibility; --- 107,120 ---- public static final int SCROLLBARS_NONE = 3; /** * Determines which scrollbars are created for the * text area. It can be one of four values : ! * {@code SCROLLBARS_BOTH} = both scrollbars.<BR> ! * {@code SCROLLBARS_HORIZONTAL_ONLY} = Horizontal bar only.<BR> ! * {@code SCROLLBARS_VERTICAL_ONLY} = Vertical bar only.<BR> ! * {@code SCROLLBARS_NONE} = No scrollbars.<BR> * * @serial * @see #getScrollbarVisibility() */ private int scrollbarVisibility;
*** 153,163 **** * Constructs a new text area with the empty string as text. * This text area is created with scrollbar visibility equal to * {@link #SCROLLBARS_BOTH}, so both vertical and horizontal * scrollbars will be visible for this text area. * @exception HeadlessException if ! * <code>GraphicsEnvironment.isHeadless</code> returns true * @see java.awt.GraphicsEnvironment#isHeadless() */ public TextArea() throws HeadlessException { this("", 0, 0, SCROLLBARS_BOTH); } --- 153,163 ---- * Constructs a new text area with the empty string as text. * This text area is created with scrollbar visibility equal to * {@link #SCROLLBARS_BOTH}, so both vertical and horizontal * scrollbars will be visible for this text area. * @exception HeadlessException if ! * {@code GraphicsEnvironment.isHeadless} returns true * @see java.awt.GraphicsEnvironment#isHeadless() */ public TextArea() throws HeadlessException { this("", 0, 0, SCROLLBARS_BOTH); }
*** 166,179 **** * Constructs a new text area with the specified text. * This text area is created with scrollbar visibility equal to * {@link #SCROLLBARS_BOTH}, so both vertical and horizontal * scrollbars will be visible for this text area. * @param text the text to be displayed; if ! * <code>text</code> is <code>null</code>, the empty ! * string <code>""</code> will be displayed * @exception HeadlessException if ! * <code>GraphicsEnvironment.isHeadless</code> returns true * @see java.awt.GraphicsEnvironment#isHeadless() */ public TextArea(String text) throws HeadlessException { this(text, 0, 0, SCROLLBARS_BOTH); } --- 166,179 ---- * Constructs a new text area with the specified text. * This text area is created with scrollbar visibility equal to * {@link #SCROLLBARS_BOTH}, so both vertical and horizontal * scrollbars will be visible for this text area. * @param text the text to be displayed; if ! * {@code text} is {@code null}, the empty ! * string {@code ""} will be displayed * @exception HeadlessException if ! * {@code GraphicsEnvironment.isHeadless} returns true * @see java.awt.GraphicsEnvironment#isHeadless() */ public TextArea(String text) throws HeadlessException { this(text, 0, 0, SCROLLBARS_BOTH); }
*** 187,197 **** * vertical and horizontal scrollbars will be visible for this * text area. * @param rows the number of rows * @param columns the number of columns * @exception HeadlessException if ! * <code>GraphicsEnvironment.isHeadless</code> returns true * @see java.awt.GraphicsEnvironment#isHeadless() */ public TextArea(int rows, int columns) throws HeadlessException { this("", rows, columns, SCROLLBARS_BOTH); } --- 187,197 ---- * vertical and horizontal scrollbars will be visible for this * text area. * @param rows the number of rows * @param columns the number of columns * @exception HeadlessException if ! * {@code GraphicsEnvironment.isHeadless} returns true * @see java.awt.GraphicsEnvironment#isHeadless() */ public TextArea(int rows, int columns) throws HeadlessException { this("", rows, columns, SCROLLBARS_BOTH); }
*** 203,258 **** * width that is platform-dependent. The text area is created with * scrollbar visibility equal to {@link #SCROLLBARS_BOTH}, so both * vertical and horizontal scrollbars will be visible for this * text area. * @param text the text to be displayed; if ! * <code>text</code> is <code>null</code>, the empty ! * string <code>""</code> will be displayed * @param rows the number of rows * @param columns the number of columns * @exception HeadlessException if ! * <code>GraphicsEnvironment.isHeadless</code> returns true * @see java.awt.GraphicsEnvironment#isHeadless() */ public TextArea(String text, int rows, int columns) throws HeadlessException { this(text, rows, columns, SCROLLBARS_BOTH); } /** * Constructs a new text area with the specified text, * and with the rows, columns, and scroll bar visibility ! * as specified. All <code>TextArea</code> constructors defer to * this one. * <p> ! * The <code>TextArea</code> class defines several constants * that can be supplied as values for the ! * <code>scrollbars</code> argument: * <ul> ! * <li><code>SCROLLBARS_BOTH</code>, ! * <li><code>SCROLLBARS_VERTICAL_ONLY</code>, ! * <li><code>SCROLLBARS_HORIZONTAL_ONLY</code>, ! * <li><code>SCROLLBARS_NONE</code>. * </ul> * Any other value for the ! * <code>scrollbars</code> argument is invalid and will result in * this text area being created with scrollbar visibility equal to * the default value of {@link #SCROLLBARS_BOTH}. * @param text the text to be displayed; if ! * <code>text</code> is <code>null</code>, the empty ! * string <code>""</code> will be displayed * @param rows the number of rows; if ! * <code>rows</code> is less than <code>0</code>, ! * <code>rows</code> is set to <code>0</code> * @param columns the number of columns; if ! * <code>columns</code> is less than <code>0</code>, ! * <code>columns</code> is set to <code>0</code> * @param scrollbars a constant that determines what * scrollbars are created to view the text area * @since 1.1 * @exception HeadlessException if ! * <code>GraphicsEnvironment.isHeadless</code> returns true * @see java.awt.GraphicsEnvironment#isHeadless() */ public TextArea(String text, int rows, int columns, int scrollbars) throws HeadlessException { super(text); --- 203,258 ---- * width that is platform-dependent. The text area is created with * scrollbar visibility equal to {@link #SCROLLBARS_BOTH}, so both * vertical and horizontal scrollbars will be visible for this * text area. * @param text the text to be displayed; if ! * {@code text} is {@code null}, the empty ! * string {@code ""} will be displayed * @param rows the number of rows * @param columns the number of columns * @exception HeadlessException if ! * {@code GraphicsEnvironment.isHeadless} returns true * @see java.awt.GraphicsEnvironment#isHeadless() */ public TextArea(String text, int rows, int columns) throws HeadlessException { this(text, rows, columns, SCROLLBARS_BOTH); } /** * Constructs a new text area with the specified text, * and with the rows, columns, and scroll bar visibility ! * as specified. All {@code TextArea} constructors defer to * this one. * <p> ! * The {@code TextArea} class defines several constants * that can be supplied as values for the ! * {@code scrollbars} argument: * <ul> ! * <li>{@code SCROLLBARS_BOTH}, ! * <li>{@code SCROLLBARS_VERTICAL_ONLY}, ! * <li>{@code SCROLLBARS_HORIZONTAL_ONLY}, ! * <li>{@code SCROLLBARS_NONE}. * </ul> * Any other value for the ! * {@code scrollbars} argument is invalid and will result in * this text area being created with scrollbar visibility equal to * the default value of {@link #SCROLLBARS_BOTH}. * @param text the text to be displayed; if ! * {@code text} is {@code null}, the empty ! * string {@code ""} will be displayed * @param rows the number of rows; if ! * {@code rows} is less than {@code 0}, ! * {@code rows} is set to {@code 0} * @param columns the number of columns; if ! * {@code columns} is less than {@code 0}, ! * {@code columns} is set to {@code 0} * @param scrollbars a constant that determines what * scrollbars are created to view the text area * @since 1.1 * @exception HeadlessException if ! * {@code GraphicsEnvironment.isHeadless} returns true * @see java.awt.GraphicsEnvironment#isHeadless() */ public TextArea(String text, int rows, int columns, int scrollbars) throws HeadlessException { super(text);
*** 271,292 **** setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardTraversalKeys); } /** ! * Construct a name for this component. Called by <code>getName</code> ! * when the name is <code>null</code>. */ String constructComponentName() { synchronized (TextArea.class) { return base + nameCounter++; } } /** ! * Creates the <code>TextArea</code>'s peer. The peer allows us to modify ! * the appearance of the <code>TextArea</code> without changing any of its * functionality. */ public void addNotify() { synchronized (getTreeLock()) { if (peer == null) --- 271,292 ---- setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardTraversalKeys); } /** ! * Construct a name for this component. Called by {@code getName} ! * when the name is {@code null}. */ String constructComponentName() { synchronized (TextArea.class) { return base + nameCounter++; } } /** ! * Creates the {@code TextArea}'s peer. The peer allows us to modify ! * the appearance of the {@code TextArea} without changing any of its * functionality. */ public void addNotify() { synchronized (getTreeLock()) { if (peer == null)
*** 296,310 **** } /** * Inserts the specified text at the specified position * in this text area. ! * <p>Note that passing <code>null</code> or inconsistent * parameters is invalid and will result in unspecified * behavior. * ! * @param str the non-<code>null</code> text to insert * @param pos the position at which to insert * @see java.awt.TextComponent#setText * @see java.awt.TextArea#replaceRange * @see java.awt.TextArea#append * @since 1.1 --- 296,310 ---- } /** * Inserts the specified text at the specified position * in this text area. ! * <p>Note that passing {@code null} or inconsistent * parameters is invalid and will result in unspecified * behavior. * ! * @param str the non-{@code null} text to insert * @param pos the position at which to insert * @see java.awt.TextComponent#setText * @see java.awt.TextArea#replaceRange * @see java.awt.TextArea#append * @since 1.1
*** 318,328 **** * in this text area. * * @param str the non-{@code null} text to insert * @param pos the position at which to insert * @deprecated As of JDK version 1.1, ! * replaced by <code>insert(String, int)</code>. */ @Deprecated public synchronized void insertText(String str, int pos) { TextAreaPeer peer = (TextAreaPeer)this.peer; if (peer != null) { --- 318,328 ---- * in this text area. * * @param str the non-{@code null} text to insert * @param pos the position at which to insert * @deprecated As of JDK version 1.1, ! * replaced by {@code insert(String, int)}. */ @Deprecated public synchronized void insertText(String str, int pos) { TextAreaPeer peer = (TextAreaPeer)this.peer; if (peer != null) {
*** 331,345 **** text = text.substring(0, pos) + str + text.substring(pos); } /** * Appends the given text to the text area's current text. ! * <p>Note that passing <code>null</code> or inconsistent * parameters is invalid and will result in unspecified * behavior. * ! * @param str the non-<code>null</code> text to append * @see java.awt.TextArea#insert * @since 1.1 */ public void append(String str) { appendText(str); --- 331,345 ---- text = text.substring(0, pos) + str + text.substring(pos); } /** * Appends the given text to the text area's current text. ! * <p>Note that passing {@code null} or inconsistent * parameters is invalid and will result in unspecified * behavior. * ! * @param str the non-{@code null} text to append * @see java.awt.TextArea#insert * @since 1.1 */ public void append(String str) { appendText(str);
*** 348,358 **** /** * Appends the given text to the text area's current text. * * @param str the text to append * @deprecated As of JDK version 1.1, ! * replaced by <code>append(String)</code>. */ @Deprecated public synchronized void appendText(String str) { insertText(str, getText().length()); } --- 348,358 ---- /** * Appends the given text to the text area's current text. * * @param str the text to append * @deprecated As of JDK version 1.1, ! * replaced by {@code append(String)}. */ @Deprecated public synchronized void appendText(String str) { insertText(str, getText().length()); }
*** 363,377 **** * position will not be replaced. The text at the start * position will be replaced (unless the start position is the * same as the end position). * The text position is zero-based. The inserted substring may be * of a different length than the text it replaces. ! * <p>Note that passing <code>null</code> or inconsistent * parameters is invalid and will result in unspecified * behavior. * ! * @param str the non-<code>null</code> text to use as * the replacement * @param start the start position * @param end the end position * @see java.awt.TextArea#insert * @since 1.1 --- 363,377 ---- * position will not be replaced. The text at the start * position will be replaced (unless the start position is the * same as the end position). * The text position is zero-based. The inserted substring may be * of a different length than the text it replaces. ! * <p>Note that passing {@code null} or inconsistent * parameters is invalid and will result in unspecified * behavior. * ! * @param str the non-{@code null} text to use as * the replacement * @param start the start position * @param end the end position * @see java.awt.TextArea#insert * @since 1.1
*** 389,399 **** * @param str the non-{@code null} text to use as * the replacement * @param start the start position * @param end the end position * @deprecated As of JDK version 1.1, ! * replaced by <code>replaceRange(String, int, int)</code>. */ @Deprecated public synchronized void replaceText(String str, int start, int end) { TextAreaPeer peer = (TextAreaPeer)this.peer; if (peer != null) { --- 389,399 ---- * @param str the non-{@code null} text to use as * the replacement * @param start the start position * @param end the end position * @deprecated As of JDK version 1.1, ! * replaced by {@code replaceRange(String, int, int)}. */ @Deprecated public synchronized void replaceText(String str, int start, int end) { TextAreaPeer peer = (TextAreaPeer)this.peer; if (peer != null) {
*** 417,428 **** * Sets the number of rows for this text area. * @param rows the number of rows * @see #getRows() * @see #setColumns(int) * @exception IllegalArgumentException if the value ! * supplied for <code>rows</code> ! * is less than <code>0</code> * @since 1.1 */ public void setRows(int rows) { int oldVal = this.rows; if (rows < 0) { --- 417,428 ---- * Sets the number of rows for this text area. * @param rows the number of rows * @see #getRows() * @see #setColumns(int) * @exception IllegalArgumentException if the value ! * supplied for {@code rows} ! * is less than {@code 0} * @since 1.1 */ public void setRows(int rows) { int oldVal = this.rows; if (rows < 0) {
*** 448,459 **** * Sets the number of columns for this text area. * @param columns the number of columns * @see #getColumns() * @see #setRows(int) * @exception IllegalArgumentException if the value ! * supplied for <code>columns</code> ! * is less than <code>0</code> * @since 1.1 */ public void setColumns(int columns) { int oldVal = this.columns; if (columns < 0) { --- 448,459 ---- * Sets the number of columns for this text area. * @param columns the number of columns * @see #getColumns() * @see #setRows(int) * @exception IllegalArgumentException if the value ! * supplied for {@code columns} ! * is less than {@code 0} * @since 1.1 */ public void setColumns(int columns) { int oldVal = this.columns; if (columns < 0) {
*** 467,479 **** /** * Returns an enumerated value that indicates which scroll bars * the text area uses. * <p> ! * The <code>TextArea</code> class defines four integer constants * that are used to specify which scroll bars are available. ! * <code>TextArea</code> has one constructor that gives the * application discretion over scroll bars. * * @return an integer that indicates which scroll bars are used * @see java.awt.TextArea#SCROLLBARS_BOTH * @see java.awt.TextArea#SCROLLBARS_VERTICAL_ONLY --- 467,479 ---- /** * Returns an enumerated value that indicates which scroll bars * the text area uses. * <p> ! * The {@code TextArea} class defines four integer constants * that are used to specify which scroll bars are available. ! * {@code TextArea} has one constructor that gives the * application discretion over scroll bars. * * @return an integer that indicates which scroll bars are used * @see java.awt.TextArea#SCROLLBARS_BOTH * @see java.awt.TextArea#SCROLLBARS_VERTICAL_ONLY
*** 508,518 **** * * @param rows the number of rows * @param columns the number of columns * @return the preferred dimensions needed for the text area * @deprecated As of JDK version 1.1, ! * replaced by <code>getPreferredSize(int, int)</code>. */ @Deprecated public Dimension preferredSize(int rows, int columns) { synchronized (getTreeLock()) { TextAreaPeer peer = (TextAreaPeer)this.peer; --- 508,518 ---- * * @param rows the number of rows * @param columns the number of columns * @return the preferred dimensions needed for the text area * @deprecated As of JDK version 1.1, ! * replaced by {@code getPreferredSize(int, int)}. */ @Deprecated public Dimension preferredSize(int rows, int columns) { synchronized (getTreeLock()) { TextAreaPeer peer = (TextAreaPeer)this.peer;
*** 532,542 **** return preferredSize(); } /** * @deprecated As of JDK version 1.1, ! * replaced by <code>getPreferredSize()</code>. */ @Deprecated public Dimension preferredSize() { synchronized (getTreeLock()) { return ((rows > 0) && (columns > 0)) ? --- 532,542 ---- return preferredSize(); } /** * @deprecated As of JDK version 1.1, ! * replaced by {@code getPreferredSize()}. */ @Deprecated public Dimension preferredSize() { synchronized (getTreeLock()) { return ((rows > 0) && (columns > 0)) ?
*** 566,576 **** * * @param rows the number of rows * @param columns the number of columns * @return the minimum size for the text area * @deprecated As of JDK version 1.1, ! * replaced by <code>getMinimumSize(int, int)</code>. */ @Deprecated public Dimension minimumSize(int rows, int columns) { synchronized (getTreeLock()) { TextAreaPeer peer = (TextAreaPeer)this.peer; --- 566,576 ---- * * @param rows the number of rows * @param columns the number of columns * @return the minimum size for the text area * @deprecated As of JDK version 1.1, ! * replaced by {@code getMinimumSize(int, int)}. */ @Deprecated public Dimension minimumSize(int rows, int columns) { synchronized (getTreeLock()) { TextAreaPeer peer = (TextAreaPeer)this.peer;
*** 590,600 **** return minimumSize(); } /** * @deprecated As of JDK version 1.1, ! * replaced by <code>getMinimumSize()</code>. */ @Deprecated public Dimension minimumSize() { synchronized (getTreeLock()) { return ((rows > 0) && (columns > 0)) ? --- 590,600 ---- return minimumSize(); } /** * @deprecated As of JDK version 1.1, ! * replaced by {@code getMinimumSize()}. */ @Deprecated public Dimension minimumSize() { synchronized (getTreeLock()) { return ((rows > 0) && (columns > 0)) ?
*** 602,616 **** super.minimumSize(); } } /** ! * Returns a string representing the state of this <code>TextArea</code>. * This method is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not be ! * <code>null</code>. * * @return the parameter string of this text area */ protected String paramString() { String sbVisStr; --- 602,616 ---- super.minimumSize(); } } /** ! * Returns a string representing the state of this {@code TextArea}. * This method is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not be ! * {@code null}. * * @return the parameter string of this text area */ protected String paramString() { String sbVisStr;
*** 648,659 **** private int textAreaSerializedDataVersion = 2; /** * Read the ObjectInputStream. * @exception HeadlessException if ! * <code>GraphicsEnvironment.isHeadless()</code> returns ! * <code>true</code> * @see java.awt.GraphicsEnvironment#isHeadless */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException, HeadlessException { --- 648,659 ---- private int textAreaSerializedDataVersion = 2; /** * Read the ObjectInputStream. * @exception HeadlessException if ! * {@code GraphicsEnvironment.isHeadless()} returns ! * {@code true} * @see java.awt.GraphicsEnvironment#isHeadless */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException, HeadlessException {
*** 687,704 **** // Accessibility support //////////////// /** ! * Returns the <code>AccessibleContext</code> associated with ! * this <code>TextArea</code>. For text areas, the ! * <code>AccessibleContext</code> takes the form of an ! * <code>AccessibleAWTTextArea</code>. ! * A new <code>AccessibleAWTTextArea</code> instance is created if necessary. * ! * @return an <code>AccessibleAWTTextArea</code> that serves as the ! * <code>AccessibleContext</code> of this <code>TextArea</code> * @since 1.3 */ public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleAWTTextArea(); --- 687,704 ---- // Accessibility support //////////////// /** ! * Returns the {@code AccessibleContext} associated with ! * this {@code TextArea}. For text areas, the ! * {@code AccessibleContext} takes the form of an ! * {@code AccessibleAWTTextArea}. ! * A new {@code AccessibleAWTTextArea} instance is created if necessary. * ! * @return an {@code AccessibleAWTTextArea} that serves as the ! * {@code AccessibleContext} of this {@code TextArea} * @since 1.3 */ public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleAWTTextArea();
*** 706,716 **** return accessibleContext; } /** * This class implements accessibility support for the ! * <code>TextArea</code> class. It provides an implementation of the * Java Accessibility API appropriate to text area user-interface elements. * @since 1.3 */ protected class AccessibleAWTTextArea extends AccessibleAWTTextComponent { --- 706,716 ---- return accessibleContext; } /** * This class implements accessibility support for the ! * {@code TextArea} class. It provides an implementation of the * Java Accessibility API appropriate to text area user-interface elements. * @since 1.3 */ protected class AccessibleAWTTextArea extends AccessibleAWTTextComponent {
< prev index next >