javax.swing.text
public abstract class JTextComponent extends JComponent implements Scrollable, Accessible
| Nested Class Summary | |
|---|---|
| class | JTextComponent.AccessibleJTextComponent
AccessibleJTextComponent implements accessibility hooks for
JTextComponent. |
| static class | JTextComponent.KeyBinding |
| Field Summary | |
|---|---|
| static String | DEFAULT_KEYMAP |
| static String | FOCUS_ACCELERATOR_KEY |
| Constructor Summary | |
|---|---|
| JTextComponent()
Creates a new JTextComponent instance. | |
| Method Summary | |
|---|---|
| void | addCaretListener(CaretListener listener)
Adds a CaretListener object to this text component.
|
| void | addInputMethodListener(InputMethodListener listener)
Adds an InputListener object to this text component.
|
| static Keymap | addKeymap(String n, Keymap parent)
Create a new Keymap with a specific name and parent, and add the new
Keymap to the global keymap table. |
| void | copy() |
| void | cut() |
| protected void | fireCaretUpdate(CaretEvent event)
Notifies all registered CaretListener objects that the caret
was updated.
|
| AccessibleContext | getAccessibleContext()
Get the AccessibleContext of this object.
|
| Action[] | getActions()
Returns the set of available Actions this component's associated
editor can run. |
| Caret | getCaret()
The Caret object used in this text component.
|
| Color | getCaretColor() |
| CaretListener[] | getCaretListeners()
Returns all added CaretListener objects.
|
| int | getCaretPosition()
Retrisves the current caret position.
|
| Color | getDisabledTextColor() |
| Document | getDocument() |
| boolean | getDragEnabled() |
| char | getFocusAccelerator() |
| Highlighter | getHighlighter() |
| InputMethodListener[] | getInputMethodListeners()
Returns all added InputMethodListener objects.
|
| static Keymap | getKeymap(String n)
Get a Keymap from the global keymap table, by name.
|
| Keymap | getKeymap()
Get the current Keymap of this component.
|
| Insets | getMargin() |
| NavigationFilter | getNavigationFilter() |
| Dimension | getPreferredScrollableViewportSize() |
| int | getScrollableBlockIncrement(Rectangle visible, int orientation, int direction) |
| boolean | getScrollableTracksViewportHeight() |
| boolean | getScrollableTracksViewportWidth() |
| int | getScrollableUnitIncrement(Rectangle visible, int orientation, int direction) |
| String | getSelectedText()
Retrieves the currently selected text in this text document.
|
| Color | getSelectedTextColor() |
| Color | getSelectionColor() |
| int | getSelectionEnd()
Returns the end postion of the currently selected text.
|
| int | getSelectionStart()
Returns the start postion of the currently selected text.
|
| String | getText()
Retrieves the current text in this text document.
|
| String | getText(int offset, int length)
Retrieves a part of the current text in this document.
|
| String | getToolTipText(MouseEvent ev)
Returns the tooltip text for this text component for the given mouse
event. |
| TextUI | getUI()
This method returns the label's UI delegate.
|
| String | getUIClassID()
Returns a string that specifies the name of the Look and Feel class
that renders this component.
|
| boolean | isEditable()
Checks whether this text component it editable.
|
| static void | loadKeymap(Keymap map, JTextComponent.KeyBinding[] bindings, Action[] actions)
Resolves a set of bindings against a set of actions and inserts the
results into a {@link Keymap}. |
| Rectangle | modelToView(int position) |
| void | moveCaretPosition(int position)
Moves the caret to a given position. |
| protected String | paramString()
Returns a string representation of this JTextComponent. |
| void | paste() |
| void | read(Reader input, Object streamDescription)
Read and set the content this component. |
| void | removeCaretListener(CaretListener listener)
Removed a CaretListener object from this text component.
|
| void | removeInputMethodListener(InputMethodListener listener)
Removes an InputListener object from this text component.
|
| static Keymap | removeKeymap(String n)
Remove a Keymap from the global Keymap table, by name.
|
| void | replaceSelection(String content) |
| void | select(int start, int end)
Selects a part of the content of the text component.
|
| void | selectAll()
Selects the whole content of the text component. |
| void | setCaret(Caret newCaret)
Sets a new Caret for this text component.
|
| void | setCaretColor(Color newColor) |
| void | setCaretPosition(int position)
Sets the caret to a new position.
|
| void | setDisabledTextColor(Color newColor) |
| void | setDocument(Document newDoc) |
| void | setDragEnabled(boolean enabled) |
| void | setEditable(boolean newValue)
Enables/disabled this text component's editability.
|
| void | setFocusAccelerator(char newKey) |
| void | setHighlighter(Highlighter newHighlighter) |
| void | setKeymap(Keymap k)
Set the current Keymap of this component, installing appropriate
{@link KeymapWrapper} and {@link KeymapActionMap} objects in the
{@link InputMap} and {@link ActionMap} parent chains, respectively,
and fire a property change event with name "keymap".
|
| void | setMargin(Insets m) |
| void | setNavigationFilter(NavigationFilter filter) |
| void | setSelectedTextColor(Color newColor) |
| void | setSelectionColor(Color newColor) |
| void | setSelectionEnd(int end)
Selects the text from the selection start postion to the given position.
|
| void | setSelectionStart(int start)
Selects the text from the given postion to the selection end position.
|
| void | setText(String text) |
| void | setUI(TextUI newUI)
This method sets the label's UI delegate.
|
| void | updateUI()
This method resets the label's UI delegate to the default UI for the
current look and feel. |
| int | viewToModel(Point pt) |
| void | write(Writer output)
Write the content of this component to the given stream. |
JTextComponent instance.CaretListener object to this text component.
Parameters: listener the listener to add
InputListener object to this text component.
Parameters: listener the listener to add
null,
in which case the new Keymap will not be added to the global
Keymap table. The parent may also be null, which is
harmless.
Parameters: n The name of the new Keymap, or null parent The parent of the new Keymap, or null
Returns: The newly created Keymap
See Also: JTextComponent getKeymap keymaps
CaretListener objects that the caret
was updated.
Parameters: event the event to send
AccessibleContext of this object.
Returns: an AccessibleContext object
getUI().getEditorKit().getActions(). This set of Actions
is a reasonable value to provide as a parameter to {@link
#loadKeymap}, when resolving a set of {@link KeyBinding} objects
against this component.
Returns: The set of available Actions on this component's {@link EditorKit}
See Also: TextUI getActions
Caret object used in this text component.
Returns: the caret object
CaretListener objects.
Returns: an array of listeners
Returns: the current position
InputMethodListener objects.
Returns: an array of listeners
Parameters: n The name of the Keymap to look up
Returns: A Keymap associated with the provided name, or
null if no such Keymap exists
See Also: JTextComponent JTextComponent keymaps
Returns: The component's current Keymap
See Also: JTextComponent keymap
Since: 1.4
Returns: the selected text
Throws: NullPointerException if the underlaying document is null
Returns: the end postion
Returns: the start postion
Returns: the text
Throws: NullPointerException if the underlaying document is null
Parameters: offset the postion of the first character length the length of the text to retrieve
Returns: the text
Throws: BadLocationException if arguments do not hold pre-conditions
Parameters: ev the mouse event
Returns: the tooltip text for this text component for the given mouse event
Returns: The label's UI delegate.
Returns: the string "TextComponentUI"
Returns: true if editable, false otherwise
b, if there exists a provided action a such
that a.getValue(Action.NAME) == b.ActionName then an
entry is added to the Keymap mapping b to
a.
Parameters: map The Keymap to add new mappings to bindings The set of bindings to add to the Keymap actions The set of actions to resolve binding names against
See Also: NAME Action actionName
Parameters: input an input stream to read from. streamDescription an object, describing the stream.
Throws: IOException if the reader throws it.
See Also: getDocument getProperty
CaretListener object from this text component.
Parameters: listener the listener to remove
InputListener object from this text component.
Parameters: listener the listener to remove
Parameters: n The name of the Keymap to remove
Returns: The keymap removed from the global table
See Also: JTextComponent getKeymap keymaps
Parameters: start the start position of the selected text end the end position of the selected text
Caret for this text component.
Parameters: newCaret the new Caret to set
Parameters: position the new position
Parameters: newValue true to make it editable, false otherwise.
"keymap".
Since: 1.4
Parameters: end the end positon of the selected text.
Parameters: start the start positon of the selected text.
Parameters: newUI The label's UI delegate.
Parameters: output the writer to write into.
Throws: IOException if the writer throws it.