Class cynosurex.awt.EnhancedTextArea
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cynosurex.awt.EnhancedTextArea

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.TextComponent
                   |
                   +----java.awt.TextArea
                           |
                           +----cynosurex.awt.EnhancedTextArea

public class EnhancedTextArea
extends TextArea
implements Runnable

EnhancedTextArea enhances the standard TextArea class by creating a multithreaded TextArea to calculate the current line and column position.

The thread is set to minimum priority, sleeps, and only wakes up to do the calculation when the cursor position changes.


Constructor Index

 o EnhancedTextArea()
Constructor to create an EnhancedTextArea.
 o EnhancedTextArea(int, int)
Constructor to create an EnhancedTextArea with the specified row(s) and column(s).
 o EnhancedTextArea(Label, Label)
Constructor to create an EnhancedTextArea with labels to display the current row and column position.
 o EnhancedTextArea(String)
Constructor to create an EnhancedTextArea with the specified String.
 o EnhancedTextArea(String, int, int)
Constructor to create an EnhancedTextArea with the specified String, row(s), and column(s).
 o EnhancedTextArea(TextField, TextField)
Constructor to create an EnhancedTextArea with textfields to display the current row and column position.

Method Index

 o getCaretColPosition()
This method returns the current caret column position.
 o getCaretRowPosition()
This method returns the current caret row position.
 o getNumOfCharacters()
This method returns the number of characters (including all white space) in the text area.
 o getNumOfLines()
This method returns the number of lines in the text area.
 o getNumOfWords()
This method returns the number of words (separated by white space) in the text area.
 o getSelectionEnd()
This method overrides the method in the super class.
 o getSelectionStart()
This method overrides the method in the super class.
 o getSelectionStartAndEnd()
This method returns the text selection start and end in an integer array with two elements.
 o getTextSelectionPatch()
This method returns the state of the text selection patch.
 o run()
This method is called by the EnhancedTextArea thread to update the current position of the cursor.
 o setCaretPosition(int, int)
This method sets the caret row and column position.
 o setCaretPosition(Position)
This method sets the caret row and column position.
 o setTextSelectionPatch(boolean)
The Java 1.1 API introduced a bug in the TextArea class, which return the wrong text selection position on OS using both carriage-return and line-feed characters.

Constructors

 o EnhancedTextArea
  public EnhancedTextArea()
Constructor to create an EnhancedTextArea.
 o EnhancedTextArea
  public EnhancedTextArea(int row,
                          int col)
Constructor to create an EnhancedTextArea with the specified row(s) and column(s).
Parameters:
row - row(s) of the initial text area
col - column(s) of the initial text area
 o EnhancedTextArea
  public EnhancedTextArea(String str)
Constructor to create an EnhancedTextArea with the specified String.
Parameters:
str - the string to be displayed in the text area
 o EnhancedTextArea
  public EnhancedTextArea(String str,
                          int row,
                          int col)
Constructor to create an EnhancedTextArea with the specified String, row(s), and column(s).
Parameters:
str - the string to be displayed in the text area
row - row(s) of the initial text area
col - column(s) of the initial text area
 o EnhancedTextArea
  public EnhancedTextArea(Label row,
                          Label col)
Constructor to create an EnhancedTextArea with labels to display the current row and column position.
Parameters:
row - label to display the current row
col - label to display the current column
 o EnhancedTextArea
  public EnhancedTextArea(TextField row,
                          TextField col)
Constructor to create an EnhancedTextArea with textfields to display the current row and column position.
Parameters:
row - textfield to display the current row
col - textfield to display the current column

Methods

 o getTextSelectionPatch
  public boolean getTextSelectionPatch()
This method returns the state of the text selection patch.
See Also:
setTextSelectionPatch
 o setTextSelectionPatch
  public void setTextSelectionPatch(boolean state)
The Java 1.1 API introduced a bug in the TextArea class, which return the wrong text selection position on OS using both carriage-return and line-feed characters. If this patch is set to true, EnhancedTextArea will calculate the correct text selection position.
 o getSelectionStart
  public int getSelectionStart()
This method overrides the method in the super class. It checks the text selection patch to determine if it needs to calculate the correct position. If not, it calls the method in the super class.
Overrides:
getSelectionStart in class TextComponent
See Also:
getTextSelectionPatch, setTextSelectionPatch
 o getSelectionEnd
  public int getSelectionEnd()
This method overrides the method in the super class. It checks the text selection patch to determine if it needs to calculate the correct position. If not, it calls the method in the super class.
Overrides:
getSelectionEnd in class TextComponent
See Also:
getTextSelectionPatch, setTextSelectionPatch
 o getSelectionStartAndEnd
  public int[] getSelectionStartAndEnd()
This method returns the text selection start and end in an integer array with two elements. This is the method which calculates the true cursor position if the text selection patch is set.
See Also:
getTextSelectionPatch, setTextSelectionPatch
 o getNumOfLines
  public synchronized Integer getNumOfLines()
This method returns the number of lines in the text area.
 o getNumOfWords
  public synchronized Integer getNumOfWords()
This method returns the number of words (separated by white space) in the text area.
 o getNumOfCharacters
  public synchronized Integer getNumOfCharacters()
This method returns the number of characters (including all white space) in the text area.
 o getCaretColPosition
  public int getCaretColPosition()
This method returns the current caret column position.
 o getCaretRowPosition
  public int getCaretRowPosition()
This method returns the current caret row position.
 o setCaretPosition
  public void setCaretPosition(Position p)
This method sets the caret row and column position.
Parameters:
p - position to set the caret
 o setCaretPosition
  public void setCaretPosition(int row,
                               int col)
This method sets the caret row and column position.
Parameters:
row - row to set the caret
col - column to set the caret
 o run
  public void run()
This method is called by the EnhancedTextArea thread to update the current position of the cursor. Do not call this method.

All Packages  Class Hierarchy  This Package  Previous  Next  Index