Interface TextHandler
-
- All Superinterfaces:
ComponentHandler<String>
public interface TextHandler extends 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 $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clearSelection()
Clears the selection of the text component.void
copy()
Copies the currently selected text to the system clipboard.void
cut()
Cuts the currently selected text and copies it into the system clipboard.String
getSelectedText()
Returns the currently selected text.int
getSelectionEnd()
Returns the end index of the current selection in the text field.int
getSelectionStart()
Returns the start index of the current selection in the text field.boolean
hasSelection()
Returns a flag whether the text component has a non-empty selection.void
paste()
Pastes the content of the system clipboard into this text component.void
replaceSelectedText(String text)
Replaces the text currently selected by the specified string.void
select(int start, int end)
Sets the selection of the text field.void
selectAll()
Selects all text contained in the text component.-
Methods inherited from interface net.sf.jguiraffe.gui.forms.ComponentHandler
getComponent, getData, getOuterComponent, getType, isEnabled, setData, setEnabled
-
-
-
-
Method Detail
-
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.- Returns:
- 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.- Returns:
- 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.- Returns:
- 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.- Parameters:
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.- Returns:
- the selected text
-
replaceSelectedText
void replaceSelectedText(String text)
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.- Parameters:
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.
-
-