org.apache.pivot.wtk
Class TextPane

java.lang.Object
  extended by org.apache.pivot.wtk.Component
      extended by org.apache.pivot.wtk.Container
          extended by org.apache.pivot.wtk.TextPane
All Implemented Interfaces:
Iterable<Component>, Sequence<Component>, ConstrainedVisual, Visual

@DefaultProperty(value="document")
public class TextPane
extends Container

Component that allows a user to enter and edit multiple lines of (optionally formatted) text.


Nested Class Summary
static class TextPane.ScrollDirection
          Enum representing a scroll direction.
static interface TextPane.Skin
          Text pane skin interface.
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Container
Container.EDT_Checker
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
 
Constructor Summary
TextPane()
           
 
Method Summary
 void clearSelection()
          Clears the selection.
 void copy()
           
 void cut()
           
 void delete(boolean backspace)
           
 Bounds getCharacterBounds(int offset)
           
 int getCharacterCount()
          Returns character count of the document.
 Document getDocument()
          Returns the document that backs the text pane.
 int getInsertionPoint(int x, int y)
           
 int getNextInsertionPoint(int x, int from, TextPane.ScrollDirection direction)
           
 int getRowAt(int offset)
           
 int getRowCount()
           
 String getSelectedText()
          Returns the currently selected text.
 Span getSelection()
          Returns a span representing the current selection.
 int getSelectionLength()
          Returns the length of the selection.
 int getSelectionStart()
          Returns the starting index of the selection.
 String getText()
          Convenience method to get all the text from the current document into a single string.
 String getText(int beginIndex, int endIndex)
          Convenience method to get a portion of the document text into a single string.
 ListenerList<TextPaneCharacterListener> getTextPaneCharacterListeners()
           
 ListenerList<TextPaneListener> getTextPaneListeners()
           
 ListenerList<TextPaneSelectionListener> getTextPaneSelectionListeners()
           
 void insert(char character)
           
 void insert(String text)
           
 void insertImage(Image image)
           
 void insertParagraph()
           
 boolean isEditable()
          Returns the text pane's editable flag.
 void paste()
           
 void redo()
           
 void selectAll()
          Selects all text.
 void setDocument(Document document)
          Sets the document that backs the text pane.
 void setEditable(boolean editable)
          Sets the text pane's editable flag.
 void setSelection(int selectionStart, int selectionLength)
          Sets the selection.
 void setSelection(Span selection)
          Sets the selection.
protected  void setSkin(Skin skin)
          Sets the skin, replacing any previous skin.
 void setText(String text)
          Convenience method to create a text-only document consisting of one paragraph per line of the given text.
 void undo()
           
 
Methods inherited from class org.apache.pivot.wtk.Container
add, assertEventDispatchThread, assertEventDispatchThread, clear, containsFocus, descendantAdded, descendantGainedFocus, descendantLostFocus, descendantRemoved, get, getComponentAt, getContainerListeners, getContainerMouseListeners, getDescendantAt, getFocusTraversalPolicy, getGraphics, getLength, getNamedComponent, indexOf, insert, invalidate, isAncestor, isDoubleBuffered, iterator, layout, load, mouseClick, mouseDown, mouseMove, mouseOut, mouseUp, mouseWheel, move, paint, remove, remove, removeAll, repaint, requestFocus, setDoubleBuffered, setEventDispatchThreadChecker, setFocusTraversalPolicy, setParent, setVisible, store, transferFocus, update
 
Methods inherited from class org.apache.pivot.wtk.Component
clearFocus, contains, getAncestor, getAncestor, getAttribute, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getComponentStyleListeners, getComponentTooltipListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getHeight, getHeightLimits, getLocation, getMaximumHeight, getMaximumWidth, getMenuHandler, getMinimumHeight, getMinimumWidth, getMouseLocation, getName, getNamedStyles, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getSize, getSkin, getStyles, getTooltipDelay, getTooltipText, getTooltipWrapText, getTypedStyles, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWidthLimits, getWindow, getX, getY, indexBoundsCheck, installSkin, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, mapPointFromAncestor, mapPointFromAncestor, mapPointToAncestor, mapPointToAncestor, mouseOver, reenterMouse, repaint, repaint, repaint, repaint, repaint, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setCursor, setDragSource, setDropTarget, setEnabled, setFocused, setHeight, setHeightLimits, setHeightLimits, setLocation, setLocation, setMaximumHeight, setMaximumWidth, setMenuHandler, setMinimumHeight, setMinimumWidth, setName, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setStyleName, setStyleNames, setStyleNames, setStyles, setStyles, setTooltipDelay, setTooltipText, setTooltipWrapText, setWidth, setWidthLimits, setWidthLimits, setX, setY, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextPane

public TextPane()
Method Detail

setSkin

protected void setSkin(Skin skin)
Description copied from class: Component
Sets the skin, replacing any previous skin.

Overrides:
setSkin in class Component
Parameters:
skin - The new skin.

getDocument

public Document getDocument()
Returns the document that backs the text pane.


setDocument

public void setDocument(Document document)
Sets the document that backs the text pane. Documents are not shareable across multiple TextPanes; because a Document may contain Components, and a Component may only be in one Container at a time.

Parameters:
document -

insert

public void insert(char character)

insert

public void insert(String text)

insertImage

public void insertImage(Image image)

insertParagraph

public void insertParagraph()

getCharacterCount

public int getCharacterCount()
Returns character count of the document.

Returns:
The document's character count, or 0 if the document is null.

delete

public void delete(boolean backspace)

cut

public void cut()

copy

public void copy()

paste

public void paste()

undo

public void undo()

redo

public void redo()

getText

public String getText()
Convenience method to get all the text from the current document into a single string.

Returns:
The complete text of the document as a string.
See Also:
setText(java.lang.String)

getText

public String getText(int beginIndex,
                      int endIndex)
Convenience method to get a portion of the document text into a single string.

Parameters:
beginIndex - The 0-based offset where to start retrieving text.
endIndex - The ending offset + 1 of the text to retrieve.
Returns:
The specified portion of the document text if there is any, or null if there is no document.

setText

public void setText(String text)
Convenience method to create a text-only document consisting of one paragraph per line of the given text.


getSelectionStart

public int getSelectionStart()
Returns the starting index of the selection.

Returns:
The starting index of the selection.

getSelectionLength

public int getSelectionLength()
Returns the length of the selection.

Returns:
The length of the selection; may be 0.

getSelection

public Span getSelection()
Returns a span representing the current selection.

Returns:
A span containing the current selection. Both start and end points are inclusive. Returns null if the selection is empty.

setSelection

public void setSelection(int selectionStart,
                         int selectionLength)
Sets the selection. The sum of the selection start and length must be less than the length of the text input's content.

Parameters:
selectionStart - The starting index of the selection.
selectionLength - The length of the selection.

setSelection

public final void setSelection(Span selection)
Sets the selection.

Parameters:
selection -
See Also:
setSelection(int, int)

selectAll

public void selectAll()
Selects all text.


clearSelection

public void clearSelection()
Clears the selection.


getSelectedText

public String getSelectedText()
Returns the currently selected text.

Returns:
A new string containing a copy of the text in the selected range, or null if nothing is selected.

isEditable

public boolean isEditable()
Returns the text pane's editable flag.


setEditable

public void setEditable(boolean editable)
Sets the text pane's editable flag.

Parameters:
editable -

getInsertionPoint

public int getInsertionPoint(int x,
                             int y)

getNextInsertionPoint

public int getNextInsertionPoint(int x,
                                 int from,
                                 TextPane.ScrollDirection direction)

getRowAt

public int getRowAt(int offset)

getRowCount

public int getRowCount()

getCharacterBounds

public Bounds getCharacterBounds(int offset)

getTextPaneListeners

public ListenerList<TextPaneListener> getTextPaneListeners()

getTextPaneCharacterListeners

public ListenerList<TextPaneCharacterListener> getTextPaneCharacterListeners()

getTextPaneSelectionListeners

public ListenerList<TextPaneSelectionListener> getTextPaneSelectionListeners()