Java text Area (TextArea) __java

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_63cefe150100gtek.html

The text area can enter multiple lines of text, the main methods are: TextArea (): constructs the method, creates the text area object The row number and the column number to take the default value. TextArea (String s): constructs a method that creates a text area with an initial string of s and a horizontal and vertical scroll bar in the text area. TextArea (int x,int y): Constructs a method that creates a text area object with a number of lines y, a number of columns x, and a text area with horizontal and vertical scroll bars. TextArea (string s,int x,int y): construct method, the original string of the created text area object is S, the number of rows is Y, the number of columns is x, and the text area has horizontal and vertical scroll bars. TextArea (String s,int x,int y,int scrollbar): construction method, the original string of the created text area object is S, the number of rows is Y, and the number of columns is X,scrollbar:

Textarea.scrollbars_both

Textarea.scrollbars_vertical_only

Textarea.scrollbars_horizonal_only

Textarea.scrollbars_nonePublic void SetText (String s):Sets the text in the text area to S.Public String GetText ():Gets the text in the text area.Public void Seteditable (Boolean b):Sets whether the text area is editable, and the default is editable.Public Boolean iseditable (Boolean B):Returns true if the text area is editable, otherwise returns false.Public void Insert (String s,int x):Inserts the specified text s in the position x (the number of characters at the beginning of the text area) to the text area.Public void Replacerange (String s,int start,int end):Replaces the text that starts at the specified position with the end of the specified position with the string s.Public void Append (String s):Appends text to the end of the text area.int getcaretposition:Gets the position of the input cursor in the text area.Public void setcaretposition (int position):Sets the position of the input cursor in the text area.String Getselectedtext:Gets the text selected in the text area.public int Getselectionstart:Gets the starting position of the selected text.public int Getselectionend:Gets the end position of the selected text.Public void Setselectionstart (int n):Sets the starting position of the selected text in the text area.Public void Setselectionend (int n):Sets the end position of the selected text in the text area.Public void SelectAll ():Selects all text in the text area.Public void Addtextlistener (textlistener):Adds a text monitor to the text area.Public void Removetextlistener (Textlisener):Deletes the text monitor on the text area.

TextEvent events on the text area when the content of the text area changes (such as inserting characters, deleting characters), the TextEvent class automatically creates an event object. The event source where the TextEvent event occurs is the Addtextlistener (monitor)for the monitor. The interface that handles the occurrence of the TextEvent event is TextListener, which has only one method:

textvaluechanged (textevent e); The methods in the TextEvent class are:

Public Object GetSource (): gets a reference to the event source object where the TextEvent event occurred.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.