JTextComponent (Java Platform SE 7 )

Methods

 

Modifier and Type
Method and Description

void
addCaretListener(CaretListener listener)

Adds a caret listener for notification of any changes
to the caret.

void
addInputMethodListener(InputMethodListener l)

Adds the specified input method listener to receive
input method events from this component.

static Keymap
addKeymap(String nm,
Keymap parent)

Adds a new keymap into the keymap hierarchy.

void
copy()

Transfers the currently selected range in the associated
text model to the system clipboard, leaving the contents
in the text model.

void
cut()

Transfers the currently selected range in the associated
text model to the system clipboard, removing the contents
from the model.

protected void
fireCaretUpdate(CaretEvent e)

Notifies all listeners that have registered interest for
notification on this event type.

AccessibleContext
getAccessibleContext()

Gets the AccessibleContext associated with this
JTextComponent.

Action[]
getActions()

Fetches the command list for the editor.

Caret
getCaret()

Fetches the caret that allows text-oriented navigation over
the view.

Color
getCaretColor()

Fetches the current color used to render the
caret.

CaretListener[]
getCaretListeners()

Returns an array of all the caret listeners
registered on this text component.

int
getCaretPosition()

Returns the position of the text insertion caret for the
text component.

Color
getDisabledTextColor()

Fetches the current color used to render the
disabled text.

Document
getDocument()

Fetches the model associated with the editor.

boolean
getDragEnabled()

Returns whether or not automatic drag handling is enabled.

JTextComponent.DropLocation
getDropLocation()

Returns the location that this component should visually indicate
as the drop location during a DnD operation over the component,
or null if no location is to currently be shown.

DropMode
getDropMode()

Returns the drop mode for this component.

char
getFocusAccelerator()

Returns the key accelerator that will cause the receiving
text component to get the focus.

Highlighter
getHighlighter()

Fetches the object responsible for making highlights.

InputMethodRequests
getInputMethodRequests()

Gets the input method request handler which supports
requests from input methods for this component.

Keymap
getKeymap()

Fetches the keymap currently active in this text
component.

static Keymap
getKeymap(String nm)

Fetches a named keymap previously added to the document.

Insets
getMargin()

Returns the margin between the text component’s border and
its text.

NavigationFilter
getNavigationFilter()

Returns the NavigationFilter.

Dimension
getPreferredScrollableViewportSize()

Returns the preferred size of the viewport for a view component.

Printable
getPrintable(MessageFormat headerFormat,
MessageFormat footerFormat)

Returns a Printable to use for printing the content of this
JTextComponent.

int
getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction)

Components that display logical rows or columns should compute
the scroll increment that will completely expose one block
of rows or columns, depending on the value of orientation.

boolean
getScrollableTracksViewportHeight()

Returns true if a viewport should always force the height of this
Scrollable to match the height of the viewport.

boolean
getScrollableTracksViewportWidth()

Returns true if a viewport should always force the width of this
Scrollable to match the width of the viewport.

int
getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)

Components that display logical rows or columns should compute
the scroll increment that will completely expose one new row
or column, depending on the value of orientation.

String
getSelectedText()

Returns the selected text contained in this
TextComponent.

Color
getSelectedTextColor()

Fetches the current color used to render the
selected text.

Color
getSelectionColor()

Fetches the current color used to render the
selection.

int
getSelectionEnd()

Returns the selected text’s end position.

int
getSelectionStart()

Returns the selected text’s start position.

String
getText()

Returns the text contained in this TextComponent.

String
getText(int offs,
int len)

Fetches a portion of the text represented by the
component.

String
getToolTipText(MouseEvent event)

Returns the string to be used as the tooltip for event.

TextUI
getUI()

Fetches the user-interface factory for this text-oriented editor.

boolean
isEditable()

Returns the boolean indicating whether this
TextComponent is editable or not.

static void
loadKeymap(Keymap map,
JTextComponent.KeyBinding[] bindings,
Action[] actions)

Loads a keymap with a bunch of
bindings.

Rectangle
modelToView(int pos)

Converts the given location in the model to a place in
the view coordinate system.

void
moveCaretPosition(int pos)

Moves the caret to a new position, leaving behind a mark
defined by the last time setCaretPosition was
called.

protected String
paramString()

Returns a string representation of this JTextComponent.

void
paste()

Transfers the contents of the system clipboard into the
associated text model.

boolean
print()

A convenience print method that displays a print dialog, and then
prints this JTextComponent in interactive mode with no
header or footer text.

boolean
print(MessageFormat headerFormat,
MessageFormat footerFormat)

A convenience print method that displays a print dialog, and then
prints this JTextComponent in interactive mode with
the specified header and footer text.

boolean
print(MessageFormat headerFormat,
MessageFormat footerFormat,
boolean showPrintDialog,
PrintService service,
PrintRequestAttributeSet attributes,
boolean interactive)

Prints the content of this JTextComponent.

protected void
processInputMethodEvent(InputMethodEvent e)

Processes input method events occurring on this component by
dispatching them to any registered
InputMethodListener objects.

void
read(Reader in,
Object desc)

Initializes from a stream.

void
removeCaretListener(CaretListener listener)

Removes a caret listener.

static Keymap
removeKeymap(String nm)

Removes a named keymap previously added to the document.

void
removeNotify()

Notifies this component that it no longer has a parent component.

void
replaceSelection(String content)

Replaces the currently selected content with new content
represented by the given string.

protected void
restoreComposedText()

Restores composed text previously saved by saveComposedText.

protected boolean
saveComposedText(int pos)

Saves composed text around the specified position.

void
select(int selectionStart,
int selectionEnd)

Selects the text between the specified start and end positions.

void
selectAll()

Selects all the text in the TextComponent.

void
setCaret(Caret c)

Sets the caret to be used.

void
setCaretColor(Color c)

Sets the current color used to render the caret.

void
setCaretPosition(int position)

Sets the position of the text insertion caret for the
TextComponent.

void
setComponentOrientation(ComponentOrientation o)

Sets the language-sensitive orientation that is to be used to order
the elements or text within this component.

void
setDisabledTextColor(Color c)

Sets the current color used to render the
disabled text.

void
setDocument(Document doc)

Associates the editor with a text document.

void
setDragEnabled(boolean b)

Turns on or off automatic drag handling.

void
setDropMode(DropMode dropMode)

Sets the drop mode for this component.

void
setEditable(boolean b)

Sets the specified boolean to indicate whether or not this
TextComponent should be editable.

void
setFocusAccelerator(char aKey)

Sets the key accelerator that will cause the receiving text
component to get the focus.

void
setHighlighter(Highlighter h)

Sets the highlighter to be used.

void
setKeymap(Keymap map)

Sets the keymap to use for binding events to
actions.

void
setMargin(Insets m)

Sets margin space between the text component’s border
and its text.

void
setNavigationFilter(NavigationFilter filter)

Sets the NavigationFilter.

void
setSelectedTextColor(Color c)

Sets the current color used to render the selected text.

void
setSelectionColor(Color c)

Sets the current color used to render the selection.

void
setSelectionEnd(int selectionEnd)

Sets the selection end to the specified position.

void
setSelectionStart(int selectionStart)

Sets the selection start to the specified position.

void
setText(String t)

Sets the text of this TextComponent
to the specified text.

void
setUI(TextUI ui)

Sets the user-interface factory for this text-oriented editor.

void
updateUI()

Reloads the pluggable UI.

int
viewToModel(Point pt)

Converts the given place in the view coordinate system
to the nearest representative location in the model.

void
write(Writer out)

Stores the contents of the model into the given
stream.