    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class jclass.bwt.JCTextArea

    java.lang.Object
       |
       +----java.awt.Component
               |
               +----java.awt.Container
                       |
                       +----java.awt.Panel
                               |
                               +----jclass.bwt.JCContainer
                                       |
                                       +----jclass.bwt.JCScrolledWindow
                                               |
                                               +----jclass.bwt.JCTextArea

public class JCTextArea
extends JCScrolledWindow
implements JCTextAreaInterface

A JCTextArea component is a multi-line area that displays text.

Properties

Name | Method
--- | ---
Alignment | setAlignment
Background | setBackground
CaretPosition | setCaretPosition
Columns | setColumns
CursorPosition | setCursorPosition
Editable | setEditable
Font | setFont
Foreground | setForeground
Insets | setInsets
MaximumLength | setMaximumLength
Multiline | setMultiline
Overstrike | setOverstrike
PreferredSize | setPreferredSize
Rows | setRows
ScrollbarDisplay | setScrollbarDisplay
ScrollbarOffset | setScrollbarOffset
SelectedBackground | setSelectedBackground
SelectedForeground | setSelectedForeground
SelectionEnd | setSelectionEnd
SelectionList | setSelectionList
SelectionStart | setSelectionStart
ShadowThickness | setShadowThickness
ShowCursorPosition | setShowCursorPosition
StringCase | setStringCase
Text | setText
TopCharacter | setTopCharacter
TopRow | setTopRow
Traversable | setTraversable
UserData | setUserData

Events

Class | Listener | Description
--- | --- | ---
JCTextEvent | addTextListener | Posted when the value changes
JCTextCursorEvent | addTextCursorListener | Posted when the cursor is moved

##

CASE_AS_IS
CASE_LOWER
CASE_UPPER
CENTER
LEFT
RIGHT

##

JCTextArea()
  Creates an empty JCTextArea with 5 rows and 20 columns.
JCTextArea(Applet, String, int, int)
  Creates an editable field with the text from the specified file.
JCTextArea(String)
  Creates a new JCTextArea with the specified text and 5 rows by 20 columns.
JCTextArea(String, Applet, String)
  Creates a TextArea which reads parameters from the applet's HTML file.
JCTextArea(String, int, int)
  Creates a new JCTextArea with the specified text and number of rows and columns.
JCTextArea(String, int, int, int)
  Constructs a new TextArea with the specified text and number of rows, columns, and scrollbar visibility.

##

addFocusListener(FocusListener)
  Add focus listener to the TextAreaComponent child of TextArea Since the JCTextArea itself never receives focus it is necessary to be able to set it
addKeyListener(KeyListener)
  Add key listener to the TextAreaComponent Since the JCTextArea itself never receives focus it is necessary to be able to set it
addTextCursorListener(JCTextCursorListener)
  Adds the specified JCTextCursorEvent listener to receive cursor movement events.
addTextListener(JCTextListener)
  Adds the specified listener to receive text events.
append(String)
  Appends text to the end.
appendRow(String)
  Appends a row of text.
beep()
  Emits a beep.
getAlignment()
  Gets the field's alignment.
getCaretPosition()
  Gets the position of the cursor (provided for JDK 1.1 compatibility).
getChanged()
  Returns true if the user has changed the value since the last programmatic setting.
getColumns()
  Returns the number of columns.
getCursorPosition()
  Gets the position of the cursor.
getEditable()
  Returns the boolean indicating whether this component is editable or not.
getLastPosition()
  Gets the position of the last character in the text.
getMaximumLength()
  Gets the MaximumLength value.
getMinimumSize(int)
  Returns the minimum size needed for the specified number of columns.
getMinimumSize(int, int)
  Returns the minimum size needed for the specified number of rows and columns.
getMultiline()
  Gets the Multiline value.
getOverstrike()
  Gets the Overstrike value.
getRows()
  Returns the number of rows.
getSelectedBackground()
  Gets the SelectedBackground value.
getSelectedForeground()
  Gets the SelectedForeground value.
getSelectedText()
  Returns the selected text contained in this component.
getSelectionEnd()
  Returns the selected text's end position.
getSelectionList()
  Gets the current SelectionList.
getSelectionStart()
  Returns the selected text's start position.
getShadowThickness()
  Gets the shadow's thickness.

  HTML param name/value: "ShadowThickness"/int

getShowCursorPosition()
  Gets the ShowCursorPosition value.
getStringCase()
  Gets the StringCase value.
getText()
  Returns the text contained in this component.
getTextComponent()
  Gets the internal text area.
getTopCharacter()
  Gets the position of the leftmost character on the first line currently displayed, or 0 if the component is empty.
getTopRow()
  Gets the current top-most visible row.
getViewportHeight()
  Sets the work area height to be the text area's virtual height.
getViewportWidth()
  Sets the work area width to be the text's virtual width.
gotFocus(Event, Object)
insert(String, int)
  Inserts text at the specified position.
isEditable()
  Returns the boolean indicating whether this component is editable or not.
isTraversable()
  Gets the value of the Traversable property.
pointToPosition(int, int)
  Maps a physical position to the corresponding character position.
readFile(Applet, String)
  Reads data from a file and appends it to the textarea.
readFile(InputStream)
  Reads data from a file stream and appends it to the textarea.
removeFocusListener(FocusListener)
  Remove focus listener to the TextAreaComponent child of TextArea
removeKeyListener(KeyListener)
  Remove focus listener to the TextAreaComponent
removeTextCursorListener(JCTextCursorListener)
  Removes the specified listener so it no longer receives JCTextCursorEvents.
removeTextListener(JCTextListener)
  Removes the specified text listener so it no longer receives text events.
replaceRange(String, int, int)
  Replaces the existing text between two positions with the specified text.
scrollVertical(int)
  Scrolls the window vertically to the specified row.
scrollVertical(JCScrollableInterface, JCAdjustmentEvent, int)
  Scrolls a scrollableInterface component vertically.
select(int, int)
  Selects the text found between the specified start and end locations.
selectAll()
  Selects all the text in the component.
setAlignment(int)
  Sets the position of the text:
  LEFT (default), CENTER, or RIGHT.
setCaretPosition(int)
  Sets the position of the cursor (provided for JDK 1.1 compatibility).
setColumns(int)
  Sets the number of columns.
setCursorPosition(int)
  Sets the position of the cursor.
setEditable(boolean)
  Determines whether this component is editable.
setFont(Font)
  Sets the font of the component.

  HTML param name/value: "Font"/font

setHorizScrollbarValues(int, int, int, int)
  This method may be overriden by a subclass to set the horizontal scrollbar's values.
setMaximumLength(int)
  Sets the maximum number of characters which may be entered by the user (default: BWTEnum.MAXINT).
setMultiline(boolean)
  If true (default), the user can break text into multiple lines by hitting Enter.
setOverstrike(boolean)
  If false (default), characters typed by the user are inserted into the current text.
setRows(int)
  Sets the number of rows.
setSelectedBackground(Color)
  Sets the background color of selected text (default: blue).

  HTML param name/value: "SelectedBackground"/color

setSelectedForeground(Color)
  Sets the foreground color of selected text (default: background color).

  HTML param name/value: "SelectedForeground"/color

setSelectionEnd(int)
  Gets the selected text's end position.
setSelectionList(int[])
  Sets a list of values used for multi-click.
setSelectionStart(int)
  Gets the selected text's start position.
setShadowThickness(int)
  Sets the shadow's thickness (default: 2)
setShowCursorPosition(boolean)
  If set to true (default), the cursor position will be indicated with a vertical I-beam.
setStringCase(int)
  Sets the case of text entered by the user or set programmatically:

      CASE_AS_IS       No conversion (default)
      CASE_LOWER       Convert to lower case
      CASE_UPPER       Convert to upper case

  HTML param name/value: "StringCase"/enum

setText(String)
  Sets the text of this component to the specified text.
setTextComponent(JCTextAreaComponent)
  Replaces the current internal text component.
setTopCharacter(int)
  Sets the position of the leftmost character on the first line currently displayed.
setTopRow(int)
  Sets the top-most visible row.
setTraversable(boolean)
  Sets whether the component can accept focus (default: true).

  HTML param name/value: "Traversable"/boolean

setVertScrollbarValues(int, int, int, int)
  This method may be overriden by a subclass to set the vertical scrollbar's values.
showPosition(int)
  Scrolls the text if necessary to ensure that the position is visible.
useSystemColor(boolean)
  Specifies that java.awt.SystemColor colors are to be used for new components.

##

LEFT

     public static final int LEFT

CENTER

     public static final int CENTER

RIGHT

     public static final int RIGHT

CASE_AS_IS

     public static final int CASE_AS_IS

CASE_LOWER

     public static final int CASE_LOWER

CASE_UPPER

     public static final int CASE_UPPER

##

JCTextArea

     public JCTextArea()

  Creates an empty JCTextArea with 5 rows and 20 columns. No parameters are read from an HTML file.

JCTextArea

     public JCTextArea(String text)

  Creates a new JCTextArea with the specified text and 5 rows by 20 columns. No parameters are read from an HTML file.

JCTextArea

     public JCTextArea(String text,
                       int rows,
                       int cols)

  Creates a new JCTextArea with the specified text and number of rows and columns. No parameters are read from an HTML file.

JCTextArea

     public JCTextArea(String text,
                       int rows,
                       int columns,
                       int sb_display)

  Constructs a new TextArea with the specified text and number of rows, columns, and scrollbar visibility.

  Parameters:
    sb_display - the visibility of scrollbars
  See Also:
    setScrollbarDisplay

JCTextArea

     public JCTextArea(String text,
                       Applet applet,
                       String name)

  Creates a TextArea which reads parameters from the applet's HTML file.

  Parameters:
    applet - the applet whose PARAM tags are to be read
    name - if this is not null, only parameters preceded by this name are read
  See Also:
    getParameter, JCString

JCTextArea

     public JCTextArea(Applet applet,
                       String file,
                       int rows,
                       int cols) throws IOException

  Creates an editable field with the text from the specified file.

  Parameters:
    applet - if not null, its documentBase() is used to construct a complete filename if necessary.
    file - the file to be read. If an http protocol is not specified (a ":" is not present), the current working directory is prepended to the file name
    rows,cols - the number of rows and columns to display
  Throws: IOException
    If an I/O error has occurred.
  See Also:
    readFile

##

getTextComponent

     public JCTextAreaComponent getTextComponent()

  Gets the internal text area.

setTextComponent

     public void setTextComponent(JCTextAreaComponent text)

  Replaces the current internal text component.

useSystemColor

     public static void useSystemColor(boolean v)

  Specifies that java.awt.SystemColor colors are to be used for new components. If false (default), or if running under JDK 1.0, the parent's colors are used.

  See Also:
    SystemColor

setFont

     public synchronized void setFont(Font f)

  Sets the font of the component.

  HTML param name/value: "Font"/font

  Overrides:
    setFont in class Component
  See Also:
    toFont

getViewportWidth

     protected int getViewportWidth()

  Sets the work area width to be the text's virtual width.

  Overrides:
    getViewportWidth in class JCScrolledWindow

getViewportHeight

     protected int getViewportHeight()

  Sets the work area height to be the text area's virtual height.

  Overrides:
    getViewportHeight in class JCScrolledWindow

setHorizScrollbarValues

     protected void setHorizScrollbarValues(int value,
                                            int visible,
                                            int min,
                                            int max)

  This method may be overriden by a subclass to set the horizontal scrollbar's values.

  Overrides:
    setHorizScrollbarValues in class JCScrolledWindow

setVertScrollbarValues

     protected void setVertScrollbarValues(int value,
                                           int visible,
                                           int min,
                                           int max)

  This method may be overriden by a subclass to set the vertical scrollbar's values.

  Overrides:
    setVertScrollbarValues in class JCScrolledWindow

scrollVertical

     protected void scrollVertical(JCScrollableInterface scrollable,
                                   JCAdjustmentEvent ev,
                                   int value)

  Scrolls a scrollableInterface component vertically.

  Overrides:
    scrollVertical in class JCScrolledWindow

scrollVertical

     public void scrollVertical(int row)

  Scrolls the window vertically to the specified row.

  Overrides:
    scrollVertical in class JCScrolledWindow

getMinimumSize

     public Dimension getMinimumSize(int columns)

  Returns the minimum size needed for the specified number of columns.

getMinimumSize

     public Dimension getMinimumSize(int rows,
                                     int columns)

  Returns the minimum size needed for the specified number of rows and columns.

getChanged

     public boolean getChanged()

  Returns true if the user has changed the value since the last programmatic setting.

beep

     public void beep()

  Emits a beep.

addKeyListener

     public void addKeyListener(KeyListener l)

  Add key listener to the TextAreaComponent Since the JCTextArea itself never receives focus it is necessary to be able to set it

  Overrides:
    addKeyListener in class Component
  See Also:
    removeKeyListener

removeKeyListener

     public void removeKeyListener(KeyListener l)

  Remove focus listener to the TextAreaComponent

  Overrides:
    removeKeyListener in class Component
  See Also:
    addKeyListener

addFocusListener

     public void addFocusListener(FocusListener l)

  Add focus listener to the TextAreaComponent child of TextArea Since the JCTextArea itself never receives focus it is necessary to be able to set it

  Overrides:
    addFocusListener in class Component

removeFocusListener

     public void removeFocusListener(FocusListener l)

  Remove focus listener to the TextAreaComponent child of TextArea

  Overrides:
    removeFocusListener in class Component
  See Also:
    addFocusListener

addTextListener

     public void addTextListener(JCTextListener l)

  Adds the specified listener to receive text events.

  See Also:
    JCTextEvent, JCTextListener

removeTextListener

     public void removeTextListener(JCTextListener l)

  Removes the specified text listener so it no longer receives text events.

addTextCursorListener

     public void addTextCursorListener(JCTextCursorListener l)

  Adds the specified JCTextCursorEvent listener to receive cursor movement events.

  See Also:
    JCTextCursorEvent

removeTextCursorListener

     public void removeTextCursorListener(JCTextCursorListener l)

  Removes the specified listener so it no longer receives JCTextCursorEvents.

  See Also:
    addTextCursorListener

readFile

     public void readFile(Applet applet,
                          String file) throws IOException

  Reads data from a file and appends it to the textarea.

  Parameters:
    applet - if not null, its documentBase() is used to construct a complete filename if necessary.
    file - the file to be read. If an http protocol is not specified (a ":" is not present), the current working directory is prepended to the file name
  Throws: IOException
    If an I/O error has occurred.

readFile

     public void readFile(InputStream stream) throws IOException

  Reads data from a file stream and appends it to the textarea.

  Throws: IOException
    If an I/O error has occurred.

setText

     public void setText(String t)

  Sets the text of this component to the specified text.

  See Also:
    getText

getText

     public String getText()

  Returns the text contained in this component.

  See Also:
    setText

getSelectedText

     public String getSelectedText()

  Returns the selected text contained in this component.

  See Also:
    setText

getMaximumLength

     public int getMaximumLength()

  Gets the MaximumLength value.

  See Also:
    setMaximumLength

setMaximumLength

     public void setMaximumLength(int v)

  Sets the maximum number of characters which may be entered by the user (default: BWTEnum.MAXINT). If the user attempts to enter more characters, the values will be ignored and the bell will be sounded. This value is ignored for values set programmatically.

  HTML param name/value: "MaximumLength"/int

  See Also:
    setText

getStringCase

     public int getStringCase()

  Gets the StringCase value.

  See Also:
    setStringCase

setStringCase

     public void setStringCase(int v)

  Sets the case of text entered by the user or set programmatically:

      CASE_AS_IS       No conversion (default)
      CASE_LOWER       Convert to lower case
      CASE_UPPER       Convert to upper case

  HTML param name/value: "StringCase"/enum

  Throws: IllegalArgumentException
    If an invalid value is set

isEditable

     public boolean isEditable()

  Returns the boolean indicating whether this component is editable or not.

  See Also:
    setEditable

getEditable

     public boolean getEditable()

  Returns the boolean indicating whether this component is editable or not.

  See Also:
    setEditable

setEditable

     public void setEditable(boolean t)

  Determines whether this component is editable. If ShowCursorPosition is set to true and Editable is set to false, the cursor will still appear in non-editable cells.

  See Also:
    isEditable

getSelectionStart

     public int getSelectionStart()

  Returns the selected text's start position.

getSelectionEnd

     public int getSelectionEnd()

  Returns the selected text's end position.

setSelectionStart

     public void setSelectionStart(int pos)

  Gets the selected text's start position.

setSelectionEnd

     public void setSelectionEnd(int pos)

  Gets the selected text's end position.

select

     public void select(int start,
                        int end)

  Selects the text found between the specified start and end locations.

selectAll

     public void selectAll()

  Selects all the text in the component.

insert

     public void insert(String str,
                        int pos)

  Inserts text at the specified position.

  See Also:
    setText, replaceRange

append

     public void append(String str)

  Appends text to the end. The cursor is moved to the end of the text.

  See Also:
    insert

appendRow

     public void appendRow(String str)

  Appends a row of text. The cursor is moved to the end of the text.

replaceRange

     public void replaceRange(String str,
                              int start,
                              int end)

  Replaces the existing text between two positions with the specified text.

  See Also:
    insert

getSelectionList

     public int[] getSelectionList()

  Gets the current SelectionList.

  See Also:
    setSelectionList

setSelectionList

     public void setSelectionList(int list[])

  Sets a list of values used for multi-click. As the mouse is clicked in rapid succession, each click selects the next type in the list. Valid values (in order of the default list):

       SELECT_POSITION     Selects the current pointer position
       SELECT_WORD         Selects the current word
       SELECT_LINE         Selects the current line
       SELECT_ALL          Selects all the text

  Default list: { SELECT_POSITION, SELECT_WORD, SELECT_LINE, SELECT_ALL }

setMultiline

     public void setMultiline(boolean v)

  If true (default), the user can break text into multiple lines by hitting Enter.

getMultiline

     public boolean getMultiline()

  Gets the Multiline value.

  See Also:
    setMultiline

getRows

     public int getRows()

  Returns the number of rows.

  See Also:
    setRows

getColumns

     public int getColumns()

  Returns the number of columns.

  See Also:
    setColumns

setRows

     public void setRows(int v)

  Sets the number of rows. The component will attempt to resize itself to display this number of lines in the current font.

  Throws: IllegalArgumentException
    If the value is less than 0.

setColumns

     public void setColumns(int v)

  Sets the number of columns. The component will attempt to resize itself to display this number of N's in the current font.

  Throws: IllegalArgumentException
    If the value is less than 0.

getSelectedBackground

     public Color getSelectedBackground()

  Gets the SelectedBackground value.

  See Also:
    setSelectedBackground

setSelectedBackground

     public void setSelectedBackground(Color v)

  Sets the background color of selected text (default: blue).

  HTML param name/value: "SelectedBackground"/color

  See Also:
    toColor

getSelectedForeground

     public Color getSelectedForeground()

  Gets the SelectedForeground value.

  See Also:
    setSelectedForeground

setSelectedForeground

     public void setSelectedForeground(Color v)

  Sets the foreground color of selected text (default: background color).

  HTML param name/value: "SelectedForeground"/color

  See Also:
    toColor

pointToPosition

     public int pointToPosition(int x,
                                int y)

  Maps a physical position to the corresponding character position.

showPosition

     public void showPosition(int pos)

  Scrolls the text if necessary to ensure that the position is visible.

  Parameters:
    pos - the number of characters from the beginning of the text buffer.

getTopRow

     public int getTopRow()

  Gets the current top-most visible row.

  See Also:
    setTopRow

setTopRow

     public void setTopRow(int row)

  Sets the top-most visible row.

getTopCharacter

     public int getTopCharacter()

  Gets the position of the leftmost character on the first line currently displayed, or 0 if the component is empty.

  See Also:
    setTopCharacter

setTopCharacter

     public void setTopCharacter(int pos)

  Sets the position of the leftmost character on the first line currently displayed. This is the number of characters from the beginning of the text buffer. The first character position is 0.

  See Also:
    setTopRow

getCursorPosition

     public int getCursorPosition()

  Gets the position of the cursor.

  See Also:
    setCursorPosition

setCursorPosition

     public void setCursorPosition(int pos)

  Sets the position of the cursor.

setOverstrike

     public void setOverstrike(boolean v)

  If false (default), characters typed by the user are inserted into the current text.

getOverstrike

     public boolean getOverstrike()

  Gets the Overstrike value.

  See Also:
    setOverstrike

getLastPosition

     public int getLastPosition()

  Gets the position of the last character in the text. This represents the position that text appended to the component would be placed after.

getShowCursorPosition

     public boolean getShowCursorPosition()

  Gets the ShowCursorPosition value.

  See Also:
    setShowCursorPosition

setShowCursorPosition

     public void setShowCursorPosition(boolean v)

  If set to true (default), the cursor position will be indicated with a vertical I-beam. The cursor will still appear in cells with Editable set to false.

getAlignment

     public int getAlignment()

  Gets the field's alignment.

  See Also:
    setAlignment

setAlignment

     public void setAlignment(int v)

  Sets the position of the text:
  LEFT (default), CENTER, or RIGHT. HTML param name/value: "Alignment"/enum

  Throws: IllegalArgumentException
    If an invalid value is set

getCaretPosition

     public int getCaretPosition()

  Gets the position of the cursor (provided for JDK 1.1 compatibility).

  See Also:
    getCursorPosition

setCaretPosition

     public void setCaretPosition(int pos)

  Sets the position of the cursor (provided for JDK 1.1 compatibility).

  See Also:
    setCursorPosition

gotFocus

     public boolean gotFocus(Event ev,
                             Object what)

  Overrides:
    gotFocus in class Component

getShadowThickness

     public int getShadowThickness()

  Gets the shadow's thickness.

  HTML param name/value: "ShadowThickness"/int

  See Also:
    setShadowThickness

setShadowThickness

     public void setShadowThickness(int v)

  Sets the shadow's thickness (default: 2)

isTraversable

     public boolean isTraversable()

  Gets the value of the Traversable property.

  See Also:
    setTraversable

setTraversable

     public void setTraversable(boolean v)

  Sets whether the component can accept focus (default: true).

  HTML param name/value: "Traversable"/boolean

  See Also:
    toBoolean

    All Packages  Class Hierarchy  This Package  Previous  Next  Index