JTextComponent

Extends
JComponent
Methods
20
Fields
1

Methods

MethodReturnsDescription
getText()string(JTextComponent) -> string: The whole text ("" when empty).
getText(number, number)string
setText(string?)()Replaces the text: the old text's removal, then the new text's insertion, each heard by the document's listeners before this returns. nil…
isEditable()booleanWhether the user may edit the text.
setEditable(boolean)()Lets the user edit the text, or not (the look greys a read-only one's background).
getSelectionStart()numberWhere the selection starts (the caret, without one).
getSelectionEnd()numberWhere the selection ends (the caret, without one).
getSelectedText()string?The selected text, or nil without a selection.
select(number, number)()Selects from selectionStart to selectionEnd, clamped to the text.
selectAll()()Selects the whole text.
getCaretPosition()numberThe caret's offset.
setCaretPosition(number)()Moves the caret (and empties the selection); outside the text raises IllegalArgumentException: bad position.
moveCaretPosition(number)()Moves the caret, extending the selection from where it was set.
replaceSelection(string?)()Replaces the selection with content (inserts it at the caret without one); nothing in a read-only component.
setCaretColor(Color?)()The caret's colour; nil gives the look's back.
setSelectionColor(Color?)()The selection's background; nil gives the look's back.
setSelectedTextColor(Color?)()The selected text's colour; nil gives the look's back.
setHighlighter(any)()setHighlighter(nil) stops painting the selection; any highlighter paints it again.
getDocument()DocumentThe component's Document, the same one each call.
init(JTextComponent)()The implicit no-argument constructor: the fresh state a node of this kind starts with, and nothing more. Construction runs it as every nati…
isInstance(any)booleanWhether obj is a JTextComponent object, a class(JTextComponent) subclass's included.

Fields

FieldTypeDescription
superJComponentClassJComponent's class table: the base class.

Method details

getText

getText: ((JTextComponent) -> string) & ((JTextComponent, number, number) -> string)

(JTextComponent) -> string: The whole text ("" when empty).

(JTextComponent, number, number) -> string: length characters (UTF-16 units) from offset; a range outside the text raises BadLocationException.

setText

setText: (JTextComponent, string?) -> ()

Replaces the text: the old text's removal, then the new text's insertion, each heard by the document's listeners before this returns. nil or "" empties it.

setEditable

setEditable: (JTextComponent, boolean) -> ()

Lets the user edit the text, or not (the look greys a read-only one's background).

select

select: (JTextComponent, number, number) -> ()

Selects from selectionStart to selectionEnd, clamped to the text.

setCaretPosition

setCaretPosition: (JTextComponent, number) -> ()

Moves the caret (and empties the selection); outside the text raises IllegalArgumentException: bad position.

replaceSelection

replaceSelection: (JTextComponent, string?) -> ()

Replaces the selection with content (inserts it at the caret without one); nothing in a read-only component.

init

init: (JTextComponent) -> ()

The implicit no-argument constructor: the fresh state a node of this kind starts with, and nothing more. Construction runs it as every native base's super(); new does not take it.

isInstance

isInstance: (any) -> boolean

Whether obj is a JTextComponent object, a class(JTextComponent) subclass's included.