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.
-
EnhancedTextArea()
- Constructor to create an EnhancedTextArea.
-
EnhancedTextArea(int, int)
- Constructor to create an EnhancedTextArea with the
specified row(s) and column(s).
-
EnhancedTextArea(Label, Label)
- Constructor to create an EnhancedTextArea with
labels to display the current row and column position.
-
EnhancedTextArea(String)
- Constructor to create an EnhancedTextArea with the
specified String.
-
EnhancedTextArea(String, int, int)
- Constructor to create an EnhancedTextArea with the
specified String, row(s), and column(s).
-
EnhancedTextArea(TextField, TextField)
- Constructor to create an EnhancedTextArea with
textfields to display the current row and column position.
-
getCaretColPosition()
- This method returns the current caret column position.
-
getCaretRowPosition()
- This method returns the current caret row position.
-
getNumOfCharacters()
- This method returns the number of characters (including
all white space) in the text area.
-
getNumOfLines()
- This method returns the number of lines in
the text area.
-
getNumOfWords()
- This method returns the number of words (separated by
white space) in
the text area.
-
getSelectionEnd()
- This method overrides the method in the super class.
-
getSelectionStart()
- This method overrides the method in the super class.
-
getSelectionStartAndEnd()
- This method returns the text selection
start and end in an integer array with two
elements.
-
getTextSelectionPatch()
- This method returns the state of the text selection patch.
-
run()
- This method is called by the EnhancedTextArea thread
to update the
current position of the cursor.
-
setCaretPosition(int, int)
- This method sets the caret row and column position.
-
setCaretPosition(Position)
- This method sets the caret row and column position.
-
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.
EnhancedTextArea
public EnhancedTextArea()
- Constructor to create an EnhancedTextArea.
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
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
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
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
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
getTextSelectionPatch
public boolean getTextSelectionPatch()
- This method returns the state of the text selection patch.
- See Also:
- setTextSelectionPatch
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.
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
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
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
getNumOfLines
public synchronized Integer getNumOfLines()
- This method returns the number of lines in
the text area.
getNumOfWords
public synchronized Integer getNumOfWords()
- This method returns the number of words (separated by
white space) in
the text area.
getNumOfCharacters
public synchronized Integer getNumOfCharacters()
- This method returns the number of characters (including
all white space) in the text area.
getCaretColPosition
public int getCaretColPosition()
- This method returns the current caret column position.
getCaretRowPosition
public int getCaretRowPosition()
- This method returns the current caret row position.
setCaretPosition
public void setCaretPosition(Position p)
- This method sets the caret row and column position.
- Parameters:
- p - position to set the caret
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
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