    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class jclass.bwt.JCTextAreaComponent

    java.lang.Object
       |
       +----java.awt.Component
               |
               +----java.awt.Canvas
                       |
                       +----jclass.bwt.JCComponent
                               |
                               +----jclass.bwt.JCTextComponent
                                       |
                                       +----jclass.bwt.JCTextAreaComponent

public class JCTextAreaComponent
extends JCTextComponent
implements JCScrollableInterface

A private class used by JCTextArea.

See Also:
  JCTextArea

##

scrolled_window
  Parent window.
update_scrollbars
visible_rows
  The number of visible lines.

##

JCTextAreaComponent()
  Creates an empty, editable field with 5 rows and 20 columns.
JCTextAreaComponent(Applet, String, int, int)
  Creates an editable 5-row by 20-column field with the text from the specified file.
JCTextAreaComponent(String)
  Creates an editable field with the specified text and 5 rows and 20 columns.
JCTextAreaComponent(String, Applet, String)
  Creates a TextArea which reads parameters from the applet's HTML file.
JCTextAreaComponent(String, int, int)
  Creates an editable field with the specified text and number of columns.

##

addNotify()
  Creates the peer of the canvas.
appendRow(String)
  Appends a row of text.
buildLineTable()
  Scans the text and adds it to the line table.
checkWidestRow(int)
  Checks whether the specified row is the widest.
countRows()
findWidestRow()
  Finds the width of the widest row (pixels).
getBounds(int, boolean)
  Gets the bounding rectangle of a row, or null if the row is invalid.
getCurrentFirstPosition()
getCurrentRow()
getDoubleBufferGraphics()
  Creates a double-buffer image, for subsequent retrieval via getDoubleBufferImage
getDoubleBufferImage()
  Returns the double-buffer image previously created in a call to getDoubleBufferGraphics.
getFirstPosition(int)
  Gets the text position of the first char in the row.
getHorizOrigin()
  Gets the horizontal origin.
getLine(int)
  Gets the line for the row.
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.
getNumChar(int)
  Returns the number of characters in a row.
getParameters()
  Reads the parameter values from the HTML page using the component's applet.
getRowHeight(int)
  Gets the height of a row.
getRowPosition(int)
  Gets the y position of the row, neglecting shadows and scrolling.
getRows()
  Gets the number of rows.
getText(int)
  Gets the text for a row, or null if the row is invalid.
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.
getVertOrigin()
  Gets the vertical origin.
getVisibleRows()
  Gets the number of visible rows.
getWidestRow()
  Gets the width of the widest row (pixels).
getWidth(int)
  Returns the width of a row (pixels).
insertNewLine(Event)
  Inserts a newline.
invalidate()
  Invalidates the component.
keyDown(Event, int)
  Processes keyDown events.
maxLines(int)
moveNextLine(Event)
  Moves the cursor to the next line.
movePreviousLine(Event)
  Moves the cursor to the previous line.
paintComponent(Graphics)
  Draws the text
pointToPosition(int, int)
  Maps a point to a text position.
positionToRow(int)
  Gets the row that contains the text position.
positionToX(int)
  Gets the x co-ordinate for a character position, ignoring scrolling.
positionToY(int)
  Gets the y co-ordinate for a character position, ignoring scrolling.
preferredHeight()
  Returns the height of the specified number of rows.
readFile(Applet, String)
  Reads data from a file and appends it to the field.
readFile(InputStream)
  Reads data from a file stream and appends it to the textarea.
repaintPositions(Point, Point)
  Draws the text between 2 points.
replaceTextInternal(String, int, int)
  Updates the internal text buffer and the line table entry.
reshape(int, int, int, int)
  Reshapes the Component to the specified bounding box.
scrollLineBegin(Event)
  Scrolls to the beginning of the current line.
scrollLineEnd(Event)
  Scrolls to the end of the current line.
scrollNextPage(Event)
  Scrolls down vertically by a page.
scrollPreviousPage(Event)
  Scrolls up vertically by a page.
setDoubleBuffer(boolean)
  Controls whether double-buffering is used when displaying and updating the component.

  HTML param name/value: "DoubleBuffer"/boolean

setHorizOrigin(int)
  Sets the horizontal origin prior to scrolling.
setInsets(Insets)
  Sets the spacing between the text and the edge of the component.
setMultiline(boolean)
  If true (default), the user can break text into multiple lines by hitting ENTER.

  HTML param name/value: "Multiline"/boolean

setRows(int)
  Sets the number of rows.

  HTML param name/value: "Rows"/int

setTopCharacter(int)
  Sets the position of the leftmost character on the first line currently displayed.
setTopRow(int)
  Sets the top-most visible row.
setVertOrigin(int)
  Sets the top row prior to scrolling.
showPosition(int)
  Scrolls the text if necessary to ensure that the position is visible.
updateScrollbars()
yToRow(int)
  Finds the row specified by the point.

##

scrolled_window

      protected transient JCScrolledWindow scrolled_window

  Parent window.

update_scrollbars

      protected boolean update_scrollbars

visible_rows

      protected int visible_rows

  The number of visible lines.

##

JCTextAreaComponent

      public JCTextAreaComponent()

  Creates an empty, editable field with 5 rows and 20 columns.

JCTextAreaComponent

      public JCTextAreaComponent(String text)

  Creates an editable field with the specified text and 5 rows and 20 columns.

JCTextAreaComponent

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

  Creates an editable field with the specified text and number of columns.

JCTextAreaComponent

      public JCTextAreaComponent(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

JCTextAreaComponent

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

  Creates an editable 5-row by 20-column 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

##

getParameters

      protected void getParameters()

  Reads the parameter values from the HTML page using the component's applet. The values will override those previously set.

  Overrides:
    getParameters in class JCTextComponent

readFile

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

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

  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.

setDoubleBuffer

      public void setDoubleBuffer(boolean v)

  Controls whether double-buffering is used when displaying and updating the component.

  HTML param name/value: "DoubleBuffer"/boolean

  Overrides:
    setDoubleBuffer in class JCComponent

invalidate

      public void invalidate()

  Invalidates the component.

  Overrides:
    invalidate in class Component

getDoubleBufferImage

      public Image getDoubleBufferImage()

  Returns the double-buffer image previously created in a call to getDoubleBufferGraphics.

  Overrides:
    getDoubleBufferImage in class JCComponent

getDoubleBufferGraphics

      public synchronized Graphics getDoubleBufferGraphics()

  Creates a double-buffer image, for subsequent retrieval via getDoubleBufferImage

  Overrides:
    getDoubleBufferGraphics in class JCComponent

appendRow

      public void appendRow(String text)

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

setInsets

      public void setInsets(Insets v)

  Sets the spacing between the text and the edge of the component.

  Overrides:
    setInsets in class JCComponent

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

setMultiline

      public void setMultiline(boolean v)

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

  HTML param name/value: "Multiline"/boolean

getMultiline

      public boolean getMultiline()

  Gets the Multiline value.

  See Also:
    setMultiline

getRows

      public int getRows()

  Gets the number of rows.

  See Also:
    setRows

setRows

      public void setRows(int r)

  Sets the number of rows.

  HTML param name/value: "Rows"/int

  Throws: IllegalArgumentException
    If the value is less than 0.

preferredHeight

      protected int preferredHeight()

  Returns the height of the specified number of rows.

  Overrides:
    preferredHeight in class JCTextComponent

getMinimumSize

      public Dimension getMinimumSize(int columns)

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

  Overrides:
    getMinimumSize in class JCTextComponent

getMinimumSize

      public Dimension getMinimumSize(int rows,
                                      int columns)

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

maxLines

      protected int maxLines(int height)

reshape

      public synchronized void reshape(int x,
                                       int y,
                                       int width,
                                       int height)

  Reshapes the Component to the specified bounding box.

  Overrides:
    reshape in class JCTextComponent

addNotify

      public void addNotify()

  Creates the peer of the canvas.

  Overrides:
    addNotify in class JCTextComponent

updateScrollbars

      protected void updateScrollbars()

Overrides:
  updateScrollbars in class JCTextComponent

buildLineTable

      protected void buildLineTable()

  Scans the text and adds it to the line table.

replaceTextInternal

      protected synchronized void replaceTextInternal(String str,
                                                      int start,
                                                      int end)

  Updates the internal text buffer and the line table entry.

  Overrides:
    replaceTextInternal in class JCTextComponent

positionToX

      public int positionToX(int pos)

  Gets the x co-ordinate for a character position, ignoring scrolling.

  Overrides:
    positionToX in class JCTextComponent

positionToY

      public int positionToY(int pos)

  Gets the y co-ordinate for a character position, ignoring scrolling.

  Overrides:
    positionToY in class JCTextComponent

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.
  Overrides:
    showPosition in class JCTextComponent

getRowHeight

      protected int getRowHeight(int row)

  Gets the height of a row.

getRowPosition

      protected int getRowPosition(int row)

  Gets the y position of the row, neglecting shadows and scrolling.

yToRow

      public int yToRow(int y)

  Finds the row specified by the point.

  Returns:
    BWTEnum.NOTFOUND if the text area has not been added to a container

paintComponent

      protected synchronized void paintComponent(Graphics gc)

  Draws the text

  Overrides:
    paintComponent in class JCComponent

getBounds

      public Rectangle getBounds(int row,
                                 boolean adjust)

  Gets the bounding rectangle of a row, or null if the row is invalid.

  Parameters:
    adjust - if true, the co-ordinates are adjusted by the amount that the field has been scrolled.

repaintPositions

      protected synchronized void repaintPositions(Point p1,
                                                   Point p2)

  Draws the text between 2 points.

  Overrides:
    repaintPositions in class JCTextComponent

getNumChar

      protected int getNumChar(int row)

  Returns the number of characters in a row.

getWidth

      protected int getWidth(int row)

  Returns the width of a row (pixels).

getVisibleRows

      public int getVisibleRows()

  Gets the number of visible rows.

getText

      public String getText(int row)

  Gets the text for a row, or null if the row is invalid.

getLine

      protected TextLine getLine(int row)

  Gets the line for the row.

getFirstPosition

      protected int getFirstPosition(int row)

  Gets the text position of the first char in the row.

positionToRow

      protected int positionToRow(int pos)

  Gets the row that contains the text position.

getWidestRow

      protected int getWidestRow()

  Gets the width of the widest row (pixels).

checkWidestRow

      protected void checkWidestRow(int row)

  Checks whether the specified row is the widest.

findWidestRow

      protected void findWidestRow()

  Finds the width of the widest row (pixels).

countRows

      protected int countRows()

getCurrentRow

      protected int getCurrentRow()

getCurrentFirstPosition

      protected int getCurrentFirstPosition()

pointToPosition

      public int pointToPosition(int x,
                                 int y)

  Maps a point to a text position.

  Overrides:
    pointToPosition in class JCTextComponent

scrollLineEnd

      protected void scrollLineEnd(Event ev)

  Scrolls to the end of the current line.

  Overrides:
    scrollLineEnd in class JCTextComponent

scrollLineBegin

      protected void scrollLineBegin(Event ev)

  Scrolls to the beginning of the current line.

  Overrides:
    scrollLineBegin in class JCTextComponent

moveNextLine

      protected void moveNextLine(Event ev)

  Moves the cursor to the next line. If the Shift key is pressed, the selection is extended.

movePreviousLine

      protected void movePreviousLine(Event ev)

  Moves the cursor to the previous line. If the Shift key is pressed, the selection is extended.

scrollNextPage

      protected void scrollNextPage(Event ev)

  Scrolls down vertically by a page.

scrollPreviousPage

      protected void scrollPreviousPage(Event ev)

  Scrolls up vertically by a page.

insertNewLine

      protected boolean insertNewLine(Event ev)

  Inserts a newline.

  Returns:
    false if the insertion was disallowed

keyDown

      public boolean keyDown(Event ev,
                             int key)

  Processes keyDown events.

      CTRL/A      scrollHome
      CTRL/D      deleteCurrentChar
      CTRL/E      scrollEnd
      CTRL/O      toggleOverstrike
      CTRL/C      copyToClipboard
      CTRL/X      cutToClipboard
      CTRL/V      pasteFromClipboard
      HOME        scrollHome
      END         scrollEnd
      PAGE-UP     scrollPreviousPage
      PAGE-DOWN   scrollNextPage
      UP          movePreviousLine
      DOWN        moveNextLine
      RIGHT       moveForwardChar
      LEFT        moveBackwardChar
      BS          deletePreviousChar
      DELETE      deleteCurrentChar
      ENTER       insertNewLine
      any other   insertChar

  Overrides:
    keyDown in class JCTextComponent

getHorizOrigin

      public int getHorizOrigin()

  Gets the horizontal origin.

setHorizOrigin

      public void setHorizOrigin(int v)

  Sets the horizontal origin prior to scrolling.

getVertOrigin

      public int getVertOrigin()

  Gets the vertical origin.

setVertOrigin

      public void setVertOrigin(int value)

  Sets the top row prior to scrolling.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index