JTextComponent (Java Platform SE 8 ) (original) (raw)

Modifier and Type

Method

Description

void

[addCaretListener](../../../javax/swing/text/JTextComponent.html#addCaretListener-javax.swing.event.CaretListener-)([CaretListener](../../../javax/swing/event/CaretListener.html "interface in javax.swing.event") listener)

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

void

[addInputMethodListener](../../../javax/swing/text/JTextComponent.html#addInputMethodListener-java.awt.event.InputMethodListener-)([InputMethodListener](../../../java/awt/event/InputMethodListener.html "interface in java.awt.event") l)

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

static [Keymap](../../../javax/swing/text/Keymap.html "interface in javax.swing.text")

[addKeymap](../../../javax/swing/text/JTextComponent.html#addKeymap-java.lang.String-javax.swing.text.Keymap-)([String](../../../java/lang/String.html "class in java.lang") nm,[Keymap](../../../javax/swing/text/Keymap.html "interface in javax.swing.text") parent)

Adds a new keymap into the keymap hierarchy.

void

[copy](../../../javax/swing/text/JTextComponent.html#copy--)()

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

void

[cut](../../../javax/swing/text/JTextComponent.html#cut--)()

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

protected void

[fireCaretUpdate](../../../javax/swing/text/JTextComponent.html#fireCaretUpdate-javax.swing.event.CaretEvent-)([CaretEvent](../../../javax/swing/event/CaretEvent.html "class in javax.swing.event") e)

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

[AccessibleContext](../../../javax/accessibility/AccessibleContext.html "class in javax.accessibility")

[getAccessibleContext](../../../javax/swing/text/JTextComponent.html#getAccessibleContext--)()

Gets the AccessibleContext associated with thisJTextComponent.

[Action](../../../javax/swing/Action.html "interface in javax.swing")[]

[getActions](../../../javax/swing/text/JTextComponent.html#getActions--)()

Fetches the command list for the editor.

[Caret](../../../javax/swing/text/Caret.html "interface in javax.swing.text")

[getCaret](../../../javax/swing/text/JTextComponent.html#getCaret--)()

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

[Color](../../../java/awt/Color.html "class in java.awt")

[getCaretColor](../../../javax/swing/text/JTextComponent.html#getCaretColor--)()

Fetches the current color used to render the caret.

[CaretListener](../../../javax/swing/event/CaretListener.html "interface in javax.swing.event")[]

[getCaretListeners](../../../javax/swing/text/JTextComponent.html#getCaretListeners--)()

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

int

[getCaretPosition](../../../javax/swing/text/JTextComponent.html#getCaretPosition--)()

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

[Color](../../../java/awt/Color.html "class in java.awt")

[getDisabledTextColor](../../../javax/swing/text/JTextComponent.html#getDisabledTextColor--)()

Fetches the current color used to render the disabled text.

[Document](../../../javax/swing/text/Document.html "interface in javax.swing.text")

[getDocument](../../../javax/swing/text/JTextComponent.html#getDocument--)()

Fetches the model associated with the editor.

boolean

[getDragEnabled](../../../javax/swing/text/JTextComponent.html#getDragEnabled--)()

Returns whether or not automatic drag handling is enabled.

[JTextComponent.DropLocation](../../../javax/swing/text/JTextComponent.DropLocation.html "class in javax.swing.text")

[getDropLocation](../../../javax/swing/text/JTextComponent.html#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](../../../javax/swing/DropMode.html "enum in javax.swing")

[getDropMode](../../../javax/swing/text/JTextComponent.html#getDropMode--)()

Returns the drop mode for this component.

char

[getFocusAccelerator](../../../javax/swing/text/JTextComponent.html#getFocusAccelerator--)()

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

[Highlighter](../../../javax/swing/text/Highlighter.html "interface in javax.swing.text")

[getHighlighter](../../../javax/swing/text/JTextComponent.html#getHighlighter--)()

Fetches the object responsible for making highlights.

[InputMethodRequests](../../../java/awt/im/InputMethodRequests.html "interface in java.awt.im")

[getInputMethodRequests](../../../javax/swing/text/JTextComponent.html#getInputMethodRequests--)()

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

[Keymap](../../../javax/swing/text/Keymap.html "interface in javax.swing.text")

[getKeymap](../../../javax/swing/text/JTextComponent.html#getKeymap--)()

Fetches the keymap currently active in this text component.

static [Keymap](../../../javax/swing/text/Keymap.html "interface in javax.swing.text")

[getKeymap](../../../javax/swing/text/JTextComponent.html#getKeymap-java.lang.String-)([String](../../../java/lang/String.html "class in java.lang") nm)

Fetches a named keymap previously added to the document.

[Insets](../../../java/awt/Insets.html "class in java.awt")

[getMargin](../../../javax/swing/text/JTextComponent.html#getMargin--)()

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

[NavigationFilter](../../../javax/swing/text/NavigationFilter.html "class in javax.swing.text")

[getNavigationFilter](../../../javax/swing/text/JTextComponent.html#getNavigationFilter--)()

Returns the NavigationFilter.

[Dimension](../../../java/awt/Dimension.html "class in java.awt")

[getPreferredScrollableViewportSize](../../../javax/swing/text/JTextComponent.html#getPreferredScrollableViewportSize--)()

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

[Printable](../../../java/awt/print/Printable.html "interface in java.awt.print")

[getPrintable](../../../javax/swing/text/JTextComponent.html#getPrintable-java.text.MessageFormat-java.text.MessageFormat-)([MessageFormat](../../../java/text/MessageFormat.html "class in java.text") headerFormat,[MessageFormat](../../../java/text/MessageFormat.html "class in java.text") footerFormat)

Returns a Printable to use for printing the content of thisJTextComponent.

int

[getScrollableBlockIncrement](../../../javax/swing/text/JTextComponent.html#getScrollableBlockIncrement-java.awt.Rectangle-int-int-)([Rectangle](../../../java/awt/Rectangle.html "class in java.awt") 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](../../../javax/swing/text/JTextComponent.html#getScrollableTracksViewportHeight--)()

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

boolean

[getScrollableTracksViewportWidth](../../../javax/swing/text/JTextComponent.html#getScrollableTracksViewportWidth--)()

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

int

[getScrollableUnitIncrement](../../../javax/swing/text/JTextComponent.html#getScrollableUnitIncrement-java.awt.Rectangle-int-int-)([Rectangle](../../../java/awt/Rectangle.html "class in java.awt") 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](../../../java/lang/String.html "class in java.lang")

[getSelectedText](../../../javax/swing/text/JTextComponent.html#getSelectedText--)()

Returns the selected text contained in thisTextComponent.

[Color](../../../java/awt/Color.html "class in java.awt")

[getSelectedTextColor](../../../javax/swing/text/JTextComponent.html#getSelectedTextColor--)()

Fetches the current color used to render the selected text.

[Color](../../../java/awt/Color.html "class in java.awt")

[getSelectionColor](../../../javax/swing/text/JTextComponent.html#getSelectionColor--)()

Fetches the current color used to render the selection.

int

[getSelectionEnd](../../../javax/swing/text/JTextComponent.html#getSelectionEnd--)()

Returns the selected text's end position.

int

[getSelectionStart](../../../javax/swing/text/JTextComponent.html#getSelectionStart--)()

Returns the selected text's start position.

[String](../../../java/lang/String.html "class in java.lang")

[getText](../../../javax/swing/text/JTextComponent.html#getText--)()

Returns the text contained in this TextComponent.

[String](../../../java/lang/String.html "class in java.lang")

[getText](../../../javax/swing/text/JTextComponent.html#getText-int-int-)(int offs, int len)

Fetches a portion of the text represented by the component.

[String](../../../java/lang/String.html "class in java.lang")

[getToolTipText](../../../javax/swing/text/JTextComponent.html#getToolTipText-java.awt.event.MouseEvent-)([MouseEvent](../../../java/awt/event/MouseEvent.html "class in java.awt.event") event)

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

[TextUI](../../../javax/swing/plaf/TextUI.html "class in javax.swing.plaf")

[getUI](../../../javax/swing/text/JTextComponent.html#getUI--)()

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

boolean

[isEditable](../../../javax/swing/text/JTextComponent.html#isEditable--)()

Returns the boolean indicating whether thisTextComponent is editable or not.

static void

[loadKeymap](../../../javax/swing/text/JTextComponent.html#loadKeymap-javax.swing.text.Keymap-javax.swing.text.JTextComponent.KeyBinding:A-javax.swing.Action:A-)([Keymap](../../../javax/swing/text/Keymap.html "interface in javax.swing.text") map,[JTextComponent.KeyBinding](../../../javax/swing/text/JTextComponent.KeyBinding.html "class in javax.swing.text")[] bindings,[Action](../../../javax/swing/Action.html "interface in javax.swing")[] actions)

Loads a keymap with a bunch of bindings.

[Rectangle](../../../java/awt/Rectangle.html "class in java.awt")

[modelToView](../../../javax/swing/text/JTextComponent.html#modelToView-int-)(int pos)

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

void

[moveCaretPosition](../../../javax/swing/text/JTextComponent.html#moveCaretPosition-int-)(int pos)

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

protected [String](../../../java/lang/String.html "class in java.lang")

[paramString](../../../javax/swing/text/JTextComponent.html#paramString--)()

Returns a string representation of this JTextComponent.

void

[paste](../../../javax/swing/text/JTextComponent.html#paste--)()

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

boolean

[print](../../../javax/swing/text/JTextComponent.html#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](../../../javax/swing/text/JTextComponent.html#print-java.text.MessageFormat-java.text.MessageFormat-)([MessageFormat](../../../java/text/MessageFormat.html "class in java.text") headerFormat,[MessageFormat](../../../java/text/MessageFormat.html "class in java.text") 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](../../../javax/swing/text/JTextComponent.html#print-java.text.MessageFormat-java.text.MessageFormat-boolean-javax.print.PrintService-javax.print.attribute.PrintRequestAttributeSet-boolean-)([MessageFormat](../../../java/text/MessageFormat.html "class in java.text") headerFormat,[MessageFormat](../../../java/text/MessageFormat.html "class in java.text") footerFormat, boolean showPrintDialog,[PrintService](../../../javax/print/PrintService.html "interface in javax.print") service,[PrintRequestAttributeSet](../../../javax/print/attribute/PrintRequestAttributeSet.html "interface in javax.print.attribute") attributes, boolean interactive)

Prints the content of this JTextComponent.

protected void

[processInputMethodEvent](../../../javax/swing/text/JTextComponent.html#processInputMethodEvent-java.awt.event.InputMethodEvent-)([InputMethodEvent](../../../java/awt/event/InputMethodEvent.html "class in java.awt.event") e)

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

void

[read](../../../javax/swing/text/JTextComponent.html#read-java.io.Reader-java.lang.Object-)([Reader](../../../java/io/Reader.html "class in java.io") in,[Object](../../../java/lang/Object.html "class in java.lang") desc)

Initializes from a stream.

void

[removeCaretListener](../../../javax/swing/text/JTextComponent.html#removeCaretListener-javax.swing.event.CaretListener-)([CaretListener](../../../javax/swing/event/CaretListener.html "interface in javax.swing.event") listener)

Removes a caret listener.

static [Keymap](../../../javax/swing/text/Keymap.html "interface in javax.swing.text")

[removeKeymap](../../../javax/swing/text/JTextComponent.html#removeKeymap-java.lang.String-)([String](../../../java/lang/String.html "class in java.lang") nm)

Removes a named keymap previously added to the document.

void

[removeNotify](../../../javax/swing/text/JTextComponent.html#removeNotify--)()

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

void

[replaceSelection](../../../javax/swing/text/JTextComponent.html#replaceSelection-java.lang.String-)([String](../../../java/lang/String.html "class in java.lang") content)

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

protected void

[restoreComposedText](../../../javax/swing/text/JTextComponent.html#restoreComposedText--)()

Restores composed text previously saved by saveComposedText.

protected boolean

[saveComposedText](../../../javax/swing/text/JTextComponent.html#saveComposedText-int-)(int pos)

Saves composed text around the specified position.

void

[select](../../../javax/swing/text/JTextComponent.html#select-int-int-)(int selectionStart, int selectionEnd)

Selects the text between the specified start and end positions.

void

[selectAll](../../../javax/swing/text/JTextComponent.html#selectAll--)()

Selects all the text in the TextComponent.

void

[setCaret](../../../javax/swing/text/JTextComponent.html#setCaret-javax.swing.text.Caret-)([Caret](../../../javax/swing/text/Caret.html "interface in javax.swing.text") c)

Sets the caret to be used.

void

[setCaretColor](../../../javax/swing/text/JTextComponent.html#setCaretColor-java.awt.Color-)([Color](../../../java/awt/Color.html "class in java.awt") c)

Sets the current color used to render the caret.

void

[setCaretPosition](../../../javax/swing/text/JTextComponent.html#setCaretPosition-int-)(int position)

Sets the position of the text insertion caret for theTextComponent.

void

[setComponentOrientation](../../../javax/swing/text/JTextComponent.html#setComponentOrientation-java.awt.ComponentOrientation-)([ComponentOrientation](../../../java/awt/ComponentOrientation.html "class in java.awt") o)

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

void

[setDisabledTextColor](../../../javax/swing/text/JTextComponent.html#setDisabledTextColor-java.awt.Color-)([Color](../../../java/awt/Color.html "class in java.awt") c)

Sets the current color used to render the disabled text.

void

[setDocument](../../../javax/swing/text/JTextComponent.html#setDocument-javax.swing.text.Document-)([Document](../../../javax/swing/text/Document.html "interface in javax.swing.text") doc)

Associates the editor with a text document.

void

[setDragEnabled](../../../javax/swing/text/JTextComponent.html#setDragEnabled-boolean-)(boolean b)

Turns on or off automatic drag handling.

void

[setDropMode](../../../javax/swing/text/JTextComponent.html#setDropMode-javax.swing.DropMode-)([DropMode](../../../javax/swing/DropMode.html "enum in javax.swing") dropMode)

Sets the drop mode for this component.

void

[setEditable](../../../javax/swing/text/JTextComponent.html#setEditable-boolean-)(boolean b)

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

void

[setFocusAccelerator](../../../javax/swing/text/JTextComponent.html#setFocusAccelerator-char-)(char aKey)

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

void

[setHighlighter](../../../javax/swing/text/JTextComponent.html#setHighlighter-javax.swing.text.Highlighter-)([Highlighter](../../../javax/swing/text/Highlighter.html "interface in javax.swing.text") h)

Sets the highlighter to be used.

void

[setKeymap](../../../javax/swing/text/JTextComponent.html#setKeymap-javax.swing.text.Keymap-)([Keymap](../../../javax/swing/text/Keymap.html "interface in javax.swing.text") map)

Sets the keymap to use for binding events to actions.

void

[setMargin](../../../javax/swing/text/JTextComponent.html#setMargin-java.awt.Insets-)([Insets](../../../java/awt/Insets.html "class in java.awt") m)

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

void

[setNavigationFilter](../../../javax/swing/text/JTextComponent.html#setNavigationFilter-javax.swing.text.NavigationFilter-)([NavigationFilter](../../../javax/swing/text/NavigationFilter.html "class in javax.swing.text") filter)

Sets the NavigationFilter.

void

[setSelectedTextColor](../../../javax/swing/text/JTextComponent.html#setSelectedTextColor-java.awt.Color-)([Color](../../../java/awt/Color.html "class in java.awt") c)

Sets the current color used to render the selected text.

void

[setSelectionColor](../../../javax/swing/text/JTextComponent.html#setSelectionColor-java.awt.Color-)([Color](../../../java/awt/Color.html "class in java.awt") c)

Sets the current color used to render the selection.

void

[setSelectionEnd](../../../javax/swing/text/JTextComponent.html#setSelectionEnd-int-)(int selectionEnd)

Sets the selection end to the specified position.

void

[setSelectionStart](../../../javax/swing/text/JTextComponent.html#setSelectionStart-int-)(int selectionStart)

Sets the selection start to the specified position.

void

[setText](../../../javax/swing/text/JTextComponent.html#setText-java.lang.String-)([String](../../../java/lang/String.html "class in java.lang") t)

Sets the text of this TextComponent to the specified text.

void

[setUI](../../../javax/swing/text/JTextComponent.html#setUI-javax.swing.plaf.TextUI-)([TextUI](../../../javax/swing/plaf/TextUI.html "class in javax.swing.plaf") ui)

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

void

[updateUI](../../../javax/swing/text/JTextComponent.html#updateUI--)()

Reloads the pluggable UI.

int

[viewToModel](../../../javax/swing/text/JTextComponent.html#viewToModel-java.awt.Point-)([Point](../../../java/awt/Point.html "class in java.awt") pt)

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

void

[write](../../../javax/swing/text/JTextComponent.html#write-java.io.Writer-)([Writer](../../../java/io/Writer.html "class in java.io") out)

Stores the contents of the model into the given stream.