All About Class TextArea in AWT in Java

0
146
Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 10
  •  
  •  
    136
    Shares

Class TextArea in Java
Class TextArea in AWT in Java
Class TextArea in Java

Class TextArea 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{
// Constants
public static final int SCROLLBARS_BOTH;
public static final int SCROLLBARS_HORIZONTAL_ONLY;
public static final int SCROLLBARS_NONE;
public static final int SCROLLBARS_VERTICAL_ONLY;
//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 synchronized void append(String str);
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();
public int getScrollbarVisibility();
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
public Dimension getMinimumSize(int rows, int columns);
public Dimension getMinimumSize(); 
public Dimension getPreferredSize(int rows, int columns);
public Dimension getPreferredSize();
public synchronized void insert(String str, int pos);
public synchronized void replaceRange(String str, int start, int end);
public void setColumns(int columns);
public void setRows(int rows);
}
 

Example:


TextArea ta1=new TextArea("Input text here",20,30);
 
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 10
  •  
  •  
    136
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here