buoy.widget
Class BTextArea

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.TextWidget
              extended by buoy.widget.BTextArea

public class BTextArea
extends TextWidget

A BTextArea is a multi-line text entry box. You can specify a preferred size for the text area in terms of rows and columns, but it automatically expands to be large enough to show all text contained in it. Usually, a BTextArea is used inside a BScrollPane. The settings for numbers of rows and columns are then treated as the preferred size of the visible area, and the scroll bars can be used to scroll through the text.

In addition to the event types generated by all Widgets, BTextAreas generate the following event types:

Author:
Peter Eastman

Nested Class Summary
static class BTextArea.WrapStyle
          This inner class represents a wrapping style.
 
Field Summary
static BTextArea.WrapStyle WRAP_CHARACTER
           
static BTextArea.WrapStyle WRAP_NONE
           
static BTextArea.WrapStyle WRAP_WORD
           
 
Constructor Summary
BTextArea()
          Create an empty BTextArea whose preferred numbers of rows and columns are 0.
BTextArea(int rows, int columns)
          Create an empty BTextArea.
BTextArea(java.lang.String text)
          Create a new BTextArea whose preferred numbers of rows and columns are 0.
BTextArea(java.lang.String text, int rows, int columns)
          Create a new BTextArea.
 
Method Summary
 void append(java.lang.String text)
          Append a String to the text contained in this Widget.
 int getColumns()
          Get the number of columns this text area should be wide enough to display.
 javax.swing.JTextArea getComponent()
          Get the java.awt.Component corresponding to this Widget.
 int getLineCount()
          Determine the number of lines of text contained in this text area.
 java.awt.Dimension getMinimumSize()
          Get the smallest size at which this Widget can reasonably be drawn.
 int getRows()
          Get the number of rows this text area should be tall enough to display.
 int getTabSize()
          Get the number of character widths to use for a tab character.
 BTextArea.WrapStyle getWrapStyle()
          Get the line wrap style for this text area.
 void insert(java.lang.String text, int pos)
          Insert a String into the middle of the text contained in this Widget.
 void replaceRange(java.lang.String text, int start, int end)
          Replace a part of the text contained in this Widget with a new String.
 void setColumns(int columns)
          Set the number of columns this text area should be wide enough to display.
 void setRows(int rows)
          Set the number of rows this text area should be tall enough to display.
 void setTabSize(int size)
          Set the number of character widths to use for a tab character.
 void setWrapStyle(BTextArea.WrapStyle style)
          Set the line wrap style for this text area.
 
Methods inherited from class buoy.widget.TextWidget
getCaretPosition, getLength, getSelectedText, getSelectionEnd, getSelectionStart, getText, isEditable, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart, setText
 
Methods inherited from class buoy.widget.Widget
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible
 
Methods inherited from class buoy.event.EventSource
addEventLink, addEventLink, removeEventLink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WRAP_NONE

public static final BTextArea.WrapStyle WRAP_NONE

WRAP_CHARACTER

public static final BTextArea.WrapStyle WRAP_CHARACTER

WRAP_WORD

public static final BTextArea.WrapStyle WRAP_WORD
Constructor Detail

BTextArea

public BTextArea()
Create an empty BTextArea whose preferred numbers of rows and columns are 0.


BTextArea

public BTextArea(java.lang.String text)
Create a new BTextArea whose preferred numbers of rows and columns are 0.

Parameters:
text - the initial text contained in the text area (may be null)

BTextArea

public BTextArea(int rows,
                 int columns)
Create an empty BTextArea.

Parameters:
rows - the number of rows this text area should be tall enough to display
columns - the number of columns this text area should be wide enough to display

BTextArea

public BTextArea(java.lang.String text,
                 int rows,
                 int columns)
Create a new BTextArea.

Parameters:
text - the initial text contained in the text area (may be null)
rows - the number of rows this text area should be tall enough to display
columns - the number of columns this text area should be wide enough to display
Method Detail

getComponent

public javax.swing.JTextArea getComponent()
Description copied from class: Widget
Get the java.awt.Component corresponding to this Widget.

Overrides:
getComponent in class TextWidget

getRows

public int getRows()
Get the number of rows this text area should be tall enough to display.


setRows

public void setRows(int rows)
Set the number of rows this text area should be tall enough to display.


getColumns

public int getColumns()
Get the number of columns this text area should be wide enough to display.


setColumns

public void setColumns(int columns)
Set the number of columns this text area should be wide enough to display.


getLineCount

public int getLineCount()
Determine the number of lines of text contained in this text area.


getWrapStyle

public BTextArea.WrapStyle getWrapStyle()
Get the line wrap style for this text area. This will be equal to WRAP_NONE, WRAP_CHARACTER, or WRAP_WORD.


setWrapStyle

public void setWrapStyle(BTextArea.WrapStyle style)
Set the line wrap style for this text area. This should be equal to WRAP_NONE, WRAP_CHARACTER, or WRAP_WORD.


getTabSize

public int getTabSize()
Get the number of character widths to use for a tab character.


setTabSize

public void setTabSize(int size)
Set the number of character widths to use for a tab character.


append

public void append(java.lang.String text)
Append a String to the text contained in this Widget.

This method can be safely called from any thread, not just the event dispatch thread.

Parameters:
text - the text to append

insert

public void insert(java.lang.String text,
                   int pos)
Insert a String into the middle of the text contained in this Widget.

This method can be safely called from any thread, not just the event dispatch thread.

Parameters:
text - the text to insert
pos - the position at which to insert it

replaceRange

public void replaceRange(java.lang.String text,
                         int start,
                         int end)
Replace a part of the text contained in this Widget with a new String.

This method can be safely called from any thread, not just the event dispatch thread.

Parameters:
text - the new text with which to replace the specified range
start - the beginning of the range to replace
end - the end of the range to replace

getMinimumSize

public java.awt.Dimension getMinimumSize()
Get the smallest size at which this Widget can reasonably be drawn. When a WidgetContainer lays out its contents, it will attempt never to make this Widget smaller than its minimum size.

Overrides:
getMinimumSize in class Widget


Written by Peter Eastman.