buoy.widget

Class 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(String text)
Create a new BTextArea whose preferred numbers of rows and columns are 0.
BTextArea(String text, int rows, int columns)
Create a new BTextArea.
BTextArea(int rows, int columns)
Create an empty BTextArea.

Method Summary

void
append(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.
JTextArea
getComponent()
int
getLineCount()
Determine the number of lines of text contained in this text area.
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(String text, int pos)
Insert a String into the middle of the text contained in this Widget.
void
replaceRange(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, getComponent, getLength, getSelectedText, getSelectionEnd, getSelectionStart, getText, isEditable, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart, setText

Methods inherited from class buoy.widget.Widget

addEventLink, dispatchEvent, getBackground, getBounds, getComponent, getCursor, getFont, getMaximumSize, getMinimumSize, 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, addEventLink, dispatchEvent, removeEventLink

Field Details

WRAP_CHARACTER

public static final BTextArea.WrapStyle WRAP_CHARACTER

WRAP_NONE

public static final BTextArea.WrapStyle WRAP_NONE

WRAP_WORD

public static final BTextArea.WrapStyle WRAP_WORD

Constructor Details

BTextArea

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

BTextArea

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

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

Method Details

append

public void append(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

getColumns

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

getComponent

public JTextArea getComponent()
Overrides:
getComponent in interface TextWidget

getLineCount

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

getMinimumSize

public 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 interface Widget

getRows

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

getTabSize

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

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.

insert

public void insert(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(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

setColumns

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

setRows

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

setTabSize

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

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.

Written by Peter Eastman.