< prev index next >

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

Print this page




 310      * @since      1.1
 311      */
 312     public void insert(String str, int pos) {
 313         insertText(str, pos);
 314     }
 315 
 316     /**
 317      * Inserts the specified text at the specified position
 318      * in this text area.
 319      *
 320      * @param  str the non-{@code null} text to insert
 321      * @param  pos the position at which to insert
 322      * @deprecated As of JDK version 1.1,
 323      * replaced by <code>insert(String, int)</code>.
 324      */
 325     @Deprecated
 326     public synchronized void insertText(String str, int pos) {
 327         TextAreaPeer peer = (TextAreaPeer)this.peer;
 328         if (peer != null) {
 329             peer.insert(str, pos);
 330         } else {
 331             text = text.substring(0, pos) + str + text.substring(pos);
 332         }


 333     }
 334 
 335     /**
 336      * Appends the given text to the text area's current text.
 337      * <p>Note that passing <code>null</code> or inconsistent
 338      * parameters is invalid and will result in unspecified
 339      * behavior.
 340      *
 341      * @param     str the non-<code>null</code> text to append
 342      * @see       java.awt.TextArea#insert
 343      * @since     1.1
 344      */
 345     public void append(String str) {
 346         appendText(str);
 347     }
 348 
 349     /**
 350      * Appends the given text to the text area's current text.
 351      *
 352      * @param  str the text to append
 353      * @deprecated As of JDK version 1.1,
 354      * replaced by <code>append(String)</code>.
 355      */
 356     @Deprecated
 357     public synchronized void appendText(String str) {
 358         if (peer != null) {
 359             insertText(str, getText().length());
 360         } else {
 361             text = text + str;
 362         }
 363     }
 364 
 365     /**
 366      * Replaces text between the indicated start and end positions
 367      * with the specified replacement text.  The text at the end
 368      * position will not be replaced.  The text at the start
 369      * position will be replaced (unless the start position is the
 370      * same as the end position).
 371      * The text position is zero-based.  The inserted substring may be
 372      * of a different length than the text it replaces.
 373      * <p>Note that passing <code>null</code> or inconsistent
 374      * parameters is invalid and will result in unspecified
 375      * behavior.
 376      *
 377      * @param     str      the non-<code>null</code> text to use as
 378      *                     the replacement
 379      * @param     start    the start position
 380      * @param     end      the end position
 381      * @see       java.awt.TextArea#insert
 382      * @since     1.1


 386     }
 387 
 388     /**
 389      * Replaces a range of characters between
 390      * the indicated start and end positions
 391      * with the specified replacement text (the text at the end
 392      * position will not be replaced).
 393      *
 394      * @param  str the non-{@code null} text to use as
 395      *         the replacement
 396      * @param  start the start position
 397      * @param  end the end position
 398      * @deprecated As of JDK version 1.1,
 399      * replaced by <code>replaceRange(String, int, int)</code>.
 400      */
 401     @Deprecated
 402     public synchronized void replaceText(String str, int start, int end) {
 403         TextAreaPeer peer = (TextAreaPeer)this.peer;
 404         if (peer != null) {
 405             peer.replaceRange(str, start, end);
 406         } else {
 407             text = text.substring(0, start) + str + text.substring(end);
 408         }


 409     }
 410 
 411     /**
 412      * Returns the number of rows in the text area.
 413      * @return    the number of rows in the text area
 414      * @see       #setRows(int)
 415      * @see       #getColumns()
 416      * @since     1.0
 417      */
 418     public int getRows() {
 419         return rows;
 420     }
 421 
 422     /**
 423      * Sets the number of rows for this text area.
 424      * @param       rows   the number of rows
 425      * @see         #getRows()
 426      * @see         #setColumns(int)
 427      * @exception   IllegalArgumentException   if the value
 428      *                 supplied for <code>rows</code>




 310      * @since      1.1
 311      */
 312     public void insert(String str, int pos) {
 313         insertText(str, pos);
 314     }
 315 
 316     /**
 317      * Inserts the specified text at the specified position
 318      * in this text area.
 319      *
 320      * @param  str the non-{@code null} text to insert
 321      * @param  pos the position at which to insert
 322      * @deprecated As of JDK version 1.1,
 323      * replaced by <code>insert(String, int)</code>.
 324      */
 325     @Deprecated
 326     public synchronized void insertText(String str, int pos) {
 327         TextAreaPeer peer = (TextAreaPeer)this.peer;
 328         if (peer != null) {
 329             peer.insert(str, pos);


 330         }
 331         text = (text != null) ? text.substring(0, pos) + str
 332                    + text.substring(pos) : str;
 333     }
 334 
 335     /**
 336      * Appends the given text to the text area's current text.
 337      * <p>Note that passing <code>null</code> or inconsistent
 338      * parameters is invalid and will result in unspecified
 339      * behavior.
 340      *
 341      * @param     str the non-<code>null</code> text to append
 342      * @see       java.awt.TextArea#insert
 343      * @since     1.1
 344      */
 345     public void append(String str) {
 346         insertText(str, getText().length());
 347     }
 348 
 349     /**
 350      * Appends the given text to the text area's current text.
 351      *
 352      * @param  str the text to append
 353      * @deprecated As of JDK version 1.1,
 354      * replaced by <code>append(String)</code>.
 355      */
 356     @Deprecated
 357     public synchronized void appendText(String str) {

 358             insertText(str, getText().length());



 359     }
 360 
 361     /**
 362      * Replaces text between the indicated start and end positions
 363      * with the specified replacement text.  The text at the end
 364      * position will not be replaced.  The text at the start
 365      * position will be replaced (unless the start position is the
 366      * same as the end position).
 367      * The text position is zero-based.  The inserted substring may be
 368      * of a different length than the text it replaces.
 369      * <p>Note that passing <code>null</code> or inconsistent
 370      * parameters is invalid and will result in unspecified
 371      * behavior.
 372      *
 373      * @param     str      the non-<code>null</code> text to use as
 374      *                     the replacement
 375      * @param     start    the start position
 376      * @param     end      the end position
 377      * @see       java.awt.TextArea#insert
 378      * @since     1.1


 382     }
 383 
 384     /**
 385      * Replaces a range of characters between
 386      * the indicated start and end positions
 387      * with the specified replacement text (the text at the end
 388      * position will not be replaced).
 389      *
 390      * @param  str the non-{@code null} text to use as
 391      *         the replacement
 392      * @param  start the start position
 393      * @param  end the end position
 394      * @deprecated As of JDK version 1.1,
 395      * replaced by <code>replaceRange(String, int, int)</code>.
 396      */
 397     @Deprecated
 398     public synchronized void replaceText(String str, int start, int end) {
 399         TextAreaPeer peer = (TextAreaPeer)this.peer;
 400         if (peer != null) {
 401             peer.replaceRange(str, start, end);


 402         }
 403         text = (text != null) ? text.substring(0, start) + str
 404                    + text.substring(end) : str;
 405     }
 406 
 407     /**
 408      * Returns the number of rows in the text area.
 409      * @return    the number of rows in the text area
 410      * @see       #setRows(int)
 411      * @see       #getColumns()
 412      * @since     1.0
 413      */
 414     public int getRows() {
 415         return rows;
 416     }
 417 
 418     /**
 419      * Sets the number of rows for this text area.
 420      * @param       rows   the number of rows
 421      * @see         #getRows()
 422      * @see         #setColumns(int)
 423      * @exception   IllegalArgumentException   if the value
 424      *                 supplied for <code>rows</code>


< prev index next >