All About Class TextArea in AWT in Java



TextArea class is used when large amount of text data is needed to be input/displayed.A TextArea is a multi line area for displaying text.It can be set to allow editing or to be read only.It is derived from TextComponent hence it can receive text Value changed events as well as keyPress and FocusEvents.
The structure of TextArea class is given as:

public class java.awt.TextArea extends java.awt.TextComponent{
//constructors
public TextArea();//default constructor constructs a new TextArea
public TextArea(int rows,int columns);//constructs a new TextArea with the specified number of rows and columns
public TextArea(String initialText);//constructs a new TextArea with the specified text dicplayed
public TextArea(String initialText,int rows,int columns);//constructs a new TextArea with the specified text and 
// the specified rows and columns.
//methods
public void addNotify();
public void appendText();
public String getText();//returns the current text in the box.
public void setTest(String text);//sets text to the text area.
public void insertText(String str,int pos);
public void replaceText(String str,int start,int end);
public int getColumns();
public int getRows();
protected String paramString();
public Dimension minimumSize();
public Dimension minimumSize(int rows,int cols);
public Dimension preferredSize();
public Dimension preferredSize(int rows,int cols);
public void setEditable(boolean option);
public String select(start,end);//select text characters between specified start and end characters
}
 
Example:

TextArea ta1=new TextArea("Input text here",20,30);
 

All About Class TextArea in AWT in Java All About Class TextArea in AWT in Java Reviewed by Animesh Chatterjee on November 20, 2018 Rating: 5

No comments:

Powered by Blogger.