com.threerings.opengl.gui
Class EditableTextComponent

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.TextComponent
          extended by com.threerings.opengl.gui.EditableTextComponent
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, Document.Listener, EditCommands
Direct Known Subclasses:
TextEditor, TextField

public abstract class EditableTextComponent
extends TextComponent
implements EditCommands, Document.Listener

Extends TextComponent with mechanisms shared by editable text Components.


Field Summary
 
Fields inherited from class com.threerings.opengl.gui.Component
DEFAULT, DISABLED, HOVER
 
Fields inherited from interface com.threerings.opengl.gui.text.EditCommands
ACTION, BACKSPACE, CLEAR, COPY, CURSOR_DOWN, CURSOR_LEFT, CURSOR_RIGHT, CURSOR_UP, CUT, DELETE, END_OF_LINE, PASTE, REDO, RELEASE_FOCUS, START_OF_LINE, UNDO, WORD_LEFT, WORD_RIGHT
 
Method Summary
 boolean acceptsFocus()
          Returns whether or not this component accepts the keyboard focus.
 boolean dispatchEvent(Event event)
          Instructs this component to process the supplied event.
 Document getDocument()
          Returns the underlying document used by this text field to maintain its state.
 Background getSelectionBackground()
          Returns the selection background configured for this component.
 String getText()
          Returns the text currently being displayed by this component.
 void setDocument(Document document)
          Configures this text field with a custom document.
 void setMaxLength(int maxLength)
          Configures the maximum length of this text field.
 void setPlaceholder(String placeholder)
          Set the placeholder text; shown when the field is unfocused and empty.
 void setPreferredWidth(int width)
          Configures the preferred width of this text field (the preferred height will be calculated from the font).
 void setText(String text)
          Configures this text field with the specified text for display and editing.
 void textInserted(Document document, int offset, int length)
          Called when text is inserted into a document.
 void textRemoved(Document document, int offset, int length)
          Called when text is removed from a document.
 
Methods inherited from class com.threerings.opengl.gui.TextComponent
getEffectColor, getEffectSize, getHorizontalAlignment, getLineSpacing, getTextEffect, getTextFactory, getVerticalAlignment
 
Methods inherited from class com.threerings.opengl.gui.Component
addListener, boundsToString, configUpdated, contains, createDefaultTooltipComponent, createDefaultTooltipComponent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getContext, getCursor, getFocusTarget, getHeight, getHitComponent, getInsets, getParent, getPreferredSize, getProperty, getState, getStyleConfigs, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, getTransferHandler, getWidth, getX, getY, hasFocus, invalidate, isAdded, isEnabled, isHoverable, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeAllListeners, removeListener, render, requestFocus, scrollRectToVisible, setAlpha, setBackground, setBounds, setCursor, setEnabled, setHoverable, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleConfig, setStyleConfig, setStyleConfig, setStyleConfigs, setTooltipRelativeToMouse, setTooltipText, setTransferHandler, setVisible, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setPlaceholder

public void setPlaceholder(String placeholder)
Set the placeholder text; shown when the field is unfocused and empty.


setText

public void setText(String text)
Configures this text field with the specified text for display and editing. The cursor will be adjusted if this text is shorter than its previous position.

Specified by:
setText in class TextComponent

getText

public String getText()
Description copied from class: TextComponent
Returns the text currently being displayed by this component.

Specified by:
getText in class TextComponent

setMaxLength

public void setMaxLength(int maxLength)
Configures the maximum length of this text field. This will replace any currently set document with a LengthLimitedDocument (or no document at all if maxLength is <= 0).


setDocument

public void setDocument(Document document)
Configures this text field with a custom document.


getDocument

public Document getDocument()
Returns the underlying document used by this text field to maintain its state. Changes to the document will be reflected in the text field display.


setPreferredWidth

public void setPreferredWidth(int width)
Configures the preferred width of this text field (the preferred height will be calculated from the font).


getSelectionBackground

public Background getSelectionBackground()
Returns the selection background configured for this component.


textInserted

public void textInserted(Document document,
                         int offset,
                         int length)
Description copied from interface: Document.Listener
Called when text is inserted into a document. The text will have already been inserted into the document.

Specified by:
textInserted in interface Document.Listener
Parameters:
document - the document into which text was inserted.
offset - the offset into the document of the inserted text.
length - the length of the inserted text.

textRemoved

public void textRemoved(Document document,
                        int offset,
                        int length)
Description copied from interface: Document.Listener
Called when text is removed from a document. The text will have already been removed from the document.

Specified by:
textRemoved in interface Document.Listener
Parameters:
document - the document from which text was removed.
offset - the offset into the document of the removed text.
length - the length of the removed text.

acceptsFocus

public boolean acceptsFocus()
Description copied from class: Component
Returns whether or not this component accepts the keyboard focus.

Overrides:
acceptsFocus in class Component

dispatchEvent

public boolean dispatchEvent(Event event)
Description copied from class: Component
Instructs this component to process the supplied event. If the event is not processed, it will be passed up to its parent component for processing. Derived classes should thus only call super.dispatchEvent for events that they did not "consume".

Overrides:
dispatchEvent in class Component
Returns:
true if this event was consumed, false if not.


Copyright © 2011. All Rights Reserved.