Class SingleSelectionModel
- All Implemented Interfaces:
SelectionModel
public final class SingleSelectionModel extends Object implements SelectionModel
SelectionModel supports a single selection segment.- Since:
- 24
Property Summary
| Type | Property | Description |
|---|---|---|
ReadOnlyProperty |
anchorPosition |
Anchor position property. |
ReadOnlyProperty |
caretPosition |
Caret position property. |
ReadOnlyProperty |
selection |
Selection property. |
Constructor Summary
| Constructor | Description |
|---|---|
SingleSelectionModel() |
The constructor. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
ReadOnlyProperty |
anchorPositionProperty() |
Anchor position property. |
ReadOnlyProperty |
caretPositionProperty() |
Caret position property. |
void |
clear() |
Clears the selection. |
void |
extendSelection |
Extends selection to the specified position. |
SelectionSegment |
getSelection() |
Gets the value of the selection property. |
ReadOnlyProperty |
selectionProperty() |
Selection property. |
void |
setSelection |
Replaced existing selection, if any, with the new one. |
Property Details
anchorPosition
public ReadOnlyProperty<TextPos> anchorPositionProperty
- Specified by:
-
anchorPositionPropertyin interfaceSelectionModel - Returns:
- the anchor position property
- See Also:
caretPosition
public ReadOnlyProperty<TextPos> caretPositionProperty
- Specified by:
-
caretPositionPropertyin interfaceSelectionModel - Returns:
- the caret position property
- See Also:
selection
public ReadOnlyProperty<SelectionSegment> selectionProperty
- Specified by:
-
selectionPropertyin interfaceSelectionModel - Returns:
- the selection property
- See Also:
Constructor Details
SingleSelectionModel
public SingleSelectionModel()
Method Details
clear
public void clear()
SelectionModelselectionProperty, anchorPositionProperty, and caretPositionProperty to null.- Specified by:
-
clearin interfaceSelectionModel
setSelection
public void setSelection(StyledTextModel model, TextPos anchor, TextPos caret)
SelectionModelanchorPositionProperty, and caretPositionProperty must always remain within the valid range for the document.- Specified by:
-
setSelectionin interfaceSelectionModel - Parameters:
-
model- the model, must be non-null -
anchor- the anchor position, must be non-null -
caret- the caret position, must be non-null
extendSelection
public void extendSelection(StyledTextModel model, TextPos pos)
SelectionModelsetSelection(model, pos, pos) call if the model instance is different from that passed before. While this method will accept the text position outside of the document range, the actual values of anchorPositionProperty, and caretPositionProperty must always remain within the valid range for the document.
- Specified by:
-
extendSelectionin interfaceSelectionModel - Parameters:
-
model- the model, must be non-null -
pos- the new caret position, must be non-null
anchorPositionProperty
public ReadOnlyProperty<TextPos> anchorPositionProperty()
SelectionModelnull, the selectionProperty and the caretPositionProperty are also null. Note: SelectionModel.selectionProperty(), SelectionModel.anchorPositionProperty(), and SelectionModel.caretPositionProperty() are logically connected. When a change occurs, the anchor position is updated first, followed by the caret position, followed by the selection segment.
- Specified by:
-
anchorPositionPropertyin interfaceSelectionModel - Returns:
- the
anchorPositionproperty
caretPositionProperty
public ReadOnlyProperty<TextPos> caretPositionProperty()
SelectionModelnull, the selectionProperty and the anchorPositionProperty are also null. Note: SelectionModel.selectionProperty(), SelectionModel.anchorPositionProperty(), and SelectionModel.caretPositionProperty() are logically connected. When a change occurs, the anchor position is updated first, followed by the caret position, followed by the selection segment.
- Specified by:
-
caretPositionPropertyin interfaceSelectionModel - Returns:
- the
caretPositionproperty
selectionProperty
public ReadOnlyProperty<SelectionSegment> selectionProperty()
SelectionModelnull, the anchorPositionProperty and the caretPositionProperty are also null.- Specified by:
-
selectionPropertyin interfaceSelectionModel - Returns:
- the
selectionproperty - See Also:
getSelection
public SelectionSegment getSelection()
selection property.- Specified by:
-
getSelectionin interfaceSelectionModel - Property description:
- Returns:
- the value of the
selectionproperty - See Also:
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.