Schnittstelle TextHandler
- Alle Superschnittstellen:
ComponentHandler<String>
A specialized ComponentHandler implementation for text components.
This handler class provides some extended functionality specific for text input components. Examples of this functionality include methods for querying or manipulating the text field's selection or support for clipboard operations. Using this handler interface applications gain more control of text components.
- Version:
- $Id: TextHandler.java 205 2012-01-29 18:29:57Z oheger $
- Autor:
- Oliver Heger
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidClears the selection of the text component.voidcopy()Copies the currently selected text to the system clipboard.voidcut()Cuts the currently selected text and copies it into the system clipboard.Returns the currently selected text.intReturns the end index of the current selection in the text field.intReturns the start index of the current selection in the text field.booleanReturns a flag whether the text component has a non-empty selection.voidpaste()Pastes the content of the system clipboard into this text component.voidreplaceSelectedText(String text) Replaces the text currently selected by the specified string.voidselect(int start, int end) Sets the selection of the text field.voidSelects all text contained in the text component.Von Schnittstelle geerbte Methoden net.sf.jguiraffe.gui.forms.ComponentHandler
getComponent, getData, getOuterComponent, getType, isEnabled, setData, setEnabled
-
Methodendetails
-
hasSelection
boolean hasSelection()Returns a flag whether the text component has a non-empty selection. If this method returns true, other methods can be called that operate on the selection.- Gibt zurück:
- a flag whether a selection exists
-
getSelectionStart
int getSelectionStart()Returns the start index of the current selection in the text field. The value returned by this method is only meaningful ifhasSelection()returns true.- Gibt zurück:
- the start index of the selection
-
getSelectionEnd
int getSelectionEnd()Returns the end index of the current selection in the text field. The value returned by this method is only meaningful ifhasSelection()returns true.- Gibt zurück:
- the end index of the selection
-
select
void select(int start, int end) Sets the selection of the text field. The parameters passed to this method are the start index and the end index of the selection. Indices are 0-based and are related to the characters stored in the text field.- Parameter:
start- the start index of the selectionend- the end index of the selection
-
selectAll
void selectAll()Selects all text contained in the text component. -
clearSelection
void clearSelection()Clears the selection of the text component. This does not affect the text stored in the component. Only the selection is reset. -
getSelectedText
String getSelectedText()Returns the currently selected text. The result of this method is only meaningful if a selection exists, i.e. ifhasSelection()returns true.- Gibt zurück:
- the selected text
-
replaceSelectedText
Replaces the text currently selected by the specified string. If no selection exists, the specified text is inserted at the current caret position. If there is a selection, but the replacement text is null or empty, the selected text is removed.- Parameter:
text- the replacement text
-
copy
void copy()Copies the currently selected text to the system clipboard. This is the standard edit copy action. -
cut
void cut()Cuts the currently selected text and copies it into the system clipboard. This is the standard edit cut action. -
paste
void paste()Pastes the content of the system clipboard into this text component. This is the standard edit paste action.
-