Top Description Inners Fields Constructors Methods
org.controlsfx.control

public Class ListSelectionView<T>

extends ControlsFXControl
Class Inheritance
Type Parameters
<T>
the type of the list items
Imports
impl.org.controlsfx.skin.ListSelectionViewSkin, javafx.beans.binding.Bindings, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ObservableList, javafx.event.ActionEvent, javafx.geometry.Orientation, javafx.scene.Node, javafx.scene.control.Cell, .Label, .ListCell, .ListView, .Skin, javafx.scene.input.KeyCombination, javafx.util.Callback, org.controlsfx.control.action.Action, org.controlsfx.glyphfont.FontAwesome, .Glyph, java.util.ArrayList, .List, java.util.function.Consumer

A control used to perform a multi-selection via the help of two list views. Items can be moved from one list (source) to the other (target). This can be done by either double clicking on the list items or by using one of the "move" buttons between the two lists. Buttons can be added or removed by altering the list of actions. Each list can be decorated with a header and a footer node. The default header nodes are simply two labels ("Available", "Selected").

Screenshot

Screenshot of ListSelectionView

Code Example

ListSelectionView<String> view = new ListSelectionView<>();
view.getSourceItems().add("One", "Two", "Three");
view.getTargetItems().add("Four", "Five");

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
ListSelectionView.ListSelectionAction<
Type of ListSelectionView to which this ListSelectionAction will be added.
T
>

Specialized actions for ListSelectionView which get access to both the internal list views.

public class
ListSelectionView.MoveToSource

Action use to move the selected items from the target list view to the source list view.

public class
ListSelectionView.MoveToSourceAll

Action use to all the items from the target list view to the source list view.

public class
ListSelectionView.MoveToTarget

Action use to move the selected items from the source list view to the target list view.

public class
ListSelectionView.MoveToTargetAll

Action use to move all the items from the source list view to the target list view.

Field Summary

Modifier and TypeField and Description
private ObservableList<Action>
private ObjectProperty<Callback<ListView<T>, ListCell<T>>>
private static final String
private final ObjectProperty<Orientation>
private ObservableList<Action>
private final ObjectProperty<Node>
private final ObjectProperty<Node>
private ObjectProperty<ObservableList<T>>
private ObservableList<Action>
private final ObjectProperty<Node>
private final ObjectProperty<Node>
private ObjectProperty<ObservableList<T>>

Constructor Summary

AccessConstructor and Description
public
ListSelectionView()

Constructs a new dual list view.

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<Callback<ListView<T>, ListCell<T>>>
cellFactoryProperty()

Setting a custom cell factory has the effect of deferring all cell creation, allowing for total customization of the cell.

protected Skin<ListSelectionView<T>>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final ObservableList<Action>

Returns:

An ObservableList of actions.
getActions
()

The list of actions to be shown in between the two list views.

public final Callback<ListView<T>, ListCell<T>>
getCellFactory()

Returns the current cell factory.

private static Glyph
getGlyph(FontAwesome.Glyph angleDoubleDown)

public final Orientation
getOrientation()

Returns the Orientation of the ListSelectionView - this can either be horizontal or vertical.

public final ObservableList<Action>

Returns:

An ObservableList of actions.
getSourceActions
()

These actions are shown beside the source list view.

public final Node

Returns:

the source footer node
getSourceFooter
()

Returns the value of sourceFooterProperty().

public final Node

Returns:

the source header node
getSourceHeader
()

Returns the value of sourceHeaderProperty().

public final ObservableList<T>

Returns:

An ObservableList containing the items to be shown to the user in the source list, or null if the items have previously been set to null.
getSourceItems
()

Returns an ObservableList that contains the items currently being shown to the user in the source list.

public final ObservableList<Action>

Returns:

An ObservableList of actions.
getTargetActions
()

These actions are shown beside the target list view.

public final Node

Returns:

the source header node
getTargetFooter
()

Returns the value of targetFooterProperty().

public final Node

Returns:

the source header node
getTargetHeader
()

Returns the value of targetHeaderProperty().

public final ObservableList<T>

Returns:

An ObservableList containing the items to be shown to the user in the target list, or null if the items have previously been set to null.
getTargetItems
()

Returns an ObservableList that contains the items currently being shown to the user in the target list.

public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

private static <T> void
move(ListView<T> source, ListView<T> target)

private static <T> void
move(ListView<T> source, ListView<T> target, List<T> items)

private static <T> void
moveToSource(ListView<T> sourceListView, ListView<T> targetListView)

private static <T> void
moveToSourceAll(ListView<T> sourceListView, ListView<T> targetListView)

private static <T> void
moveToTarget(ListView<T> sourceListView, ListView<T> targetListView)

private static <T> void
moveToTargetAll(ListView<T> sourceListView, ListView<T> targetListView)

public final ObjectProperty<Orientation>
orientationProperty()

The Orientation of the ListSelectionView - this can either be horizontal or vertical.

public final void
setCellFactory(Callback<ListView<T>, ListCell<T>> value)

Sets a new cell factory to use by both list views.

public final void
setOrientation(Orientation value)

Sets the Orientation of the ListSelectionView - this can either be horizontal or vertical.

public final void
setSourceFooter(Node
the new node shown below the source list
node
)

Sets the value of sourceFooterProperty().

public final void
setSourceHeader(Node
the new header node to use for the source list
node
)

Sets the value of sourceHeaderProperty().

public final void
setSourceItems(ObservableList<T> value)

Sets the underlying data model for the ListView.

public final void
setTargetFooter(Node
the new node shown below the target list
node
)

Sets the value of targetFooterProperty().

public final void
setTargetHeader(Node
the new node shown above the target list
node
)

Sets the value of targetHeaderProperty().

public final void
setTargetItems(ObservableList<T> value)

Sets the underlying data model for the ListView.

public final ObjectProperty<Node>

Returns:

the property used to store the source footer node
sourceFooterProperty
()

A property used to store a reference to a node that will be displayed below the source list view.

public final ObjectProperty<Node>

Returns:

the property used to store the source header node
sourceHeaderProperty
()

A property used to store a reference to a node that will be displayed above the source list view.

public final ObjectProperty<ObservableList<T>>
sourceItemsProperty()

The underlying data model for the source list view.

public final ObjectProperty<Node>

Returns:

the property used to store the source footer node
targetFooterProperty
()

A property used to store a reference to a node that will be displayed below the target list view.

public final ObjectProperty<Node>

Returns:

the property used to store the target header node
targetHeaderProperty
()

A property used to store a reference to a node that will be displayed above the target list view.

public final ObjectProperty<ObservableList<T>>
targetItemsProperty()

The underlying data model for the target list view.

Inherited from org.controlsfx.control.ControlsFXControl:
getUserAgentStylesheet

Field Detail

actionsback to summary
private ObservableList<Action> actions
cellFactoryback to summary
private ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactory
DEFAULT_STYLECLASSback to summary
private static final String DEFAULT_STYLECLASS
orientationback to summary
private final ObjectProperty<Orientation> orientation
sourceActionsback to summary
private ObservableList<Action> sourceActions
sourceFooterback to summary
private final ObjectProperty<Node> sourceFooter
sourceHeaderback to summary
private final ObjectProperty<Node> sourceHeader
sourceItemsback to summary
private ObjectProperty<ObservableList<T>> sourceItems
targetActionsback to summary
private ObservableList<Action> targetActions
targetFooterback to summary
private final ObjectProperty<Node> targetFooter
targetHeaderback to summary
private final ObjectProperty<Node> targetHeader
targetItemsback to summary
private ObjectProperty<ObservableList<T>> targetItems

Constructor Detail

ListSelectionViewback to summary
public ListSelectionView()

Constructs a new dual list view.

Method Detail

cellFactoryPropertyback to summary
public final ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactoryProperty()

Setting a custom cell factory has the effect of deferring all cell creation, allowing for total customization of the cell. Internally, the ListView is responsible for reusing ListCells - all that is necessary is for the custom cell factory to return from this function a ListCell which might be usable for representing any item in the ListView.

Refer to the Cell class documentation for more detail.

createDefaultSkinback to summary
protected Skin<ListSelectionView<T>> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
getActionsback to summary
public final ObservableList<Action> getActions()

The list of actions to be shown in between the two list views. All actions except, org.controlsfx.control.action.ActionUtils#ACTION_SEPARATOR and org.controlsfx.control.action.ActionUtils#ACTION_SPAN, are represented as buttons.

For actions dependent on both the internal list views, an instance of ListSelectionAction should be used.

By default, the list has 4 actions - MoveToTarget, MoveToTargetAll, MoveToSource and MoveToSourceAll. A user may choose to add on top of these actions or replace them depending on their use case.

Returns:ObservableList<Action>

An ObservableList of actions.

getCellFactoryback to summary
public final Callback<ListView<T>, ListCell<T>> getCellFactory()

Returns the current cell factory.

getGlyphback to summary
private static Glyph getGlyph(FontAwesome.Glyph angleDoubleDown)
getOrientationback to summary
public final Orientation getOrientation()

Returns the Orientation of the ListSelectionView - this can either be horizontal or vertical.

getSourceActionsback to summary
public final ObservableList<Action> getSourceActions()

These actions are shown beside the source list view. An instance of ListActionView.ListAction should be used where actions are dependent on the source ListView.

Returns:ObservableList<Action>

An ObservableList of actions.

See Also
ListActionView.ListAction
getSourceFooterback to summary
public final Node getSourceFooter()

Returns the value of sourceFooterProperty().

Returns:Node

the source footer node

getSourceHeaderback to summary
public final Node getSourceHeader()

Returns the value of sourceHeaderProperty().

Returns:Node

the source header node

getSourceItemsback to summary
public final ObservableList<T> getSourceItems()

Returns an ObservableList that contains the items currently being shown to the user in the source list. This may be null if setSourceItems(javafx.collections.ObservableList) has previously been called, however, by default it is an empty ObservableList.

Returns:ObservableList<T>

An ObservableList containing the items to be shown to the user in the source list, or null if the items have previously been set to null.

getTargetActionsback to summary
public final ObservableList<Action> getTargetActions()

These actions are shown beside the target list view. An instance of ListActionView.ListAction should be used where actions are dependent on the target ListView.

Returns:ObservableList<Action>

An ObservableList of actions.

See Also
ListActionView.ListAction
getTargetFooterback to summary
public final Node getTargetFooter()

Returns the value of targetFooterProperty().

Returns:Node

the source header node

getTargetHeaderback to summary
public final Node getTargetHeader()

Returns the value of targetHeaderProperty().

Returns:Node

the source header node

getTargetItemsback to summary
public final ObservableList<T> getTargetItems()

Returns an ObservableList that contains the items currently being shown to the user in the target list. This may be null if setTargetItems(javafx.collections.ObservableList) has previously been called, however, by default it is an empty ObservableList.

Returns:ObservableList<T>

An ObservableList containing the items to be shown to the user in the target list, or null if the items have previously been set to null.

getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls.

The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.

Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
moveback to summary
private static <T> void move(ListView<T> source, ListView<T> target)
moveback to summary
private static <T> void move(ListView<T> source, ListView<T> target, List<T> items)
moveToSourceback to summary
private static <T> void moveToSource(ListView<T> sourceListView, ListView<T> targetListView)
moveToSourceAllback to summary
private static <T> void moveToSourceAll(ListView<T> sourceListView, ListView<T> targetListView)
moveToTargetback to summary
private static <T> void moveToTarget(ListView<T> sourceListView, ListView<T> targetListView)
moveToTargetAllback to summary
private static <T> void moveToTargetAll(ListView<T> sourceListView, ListView<T> targetListView)
orientationPropertyback to summary
public final ObjectProperty<Orientation> orientationProperty()

The Orientation of the ListSelectionView - this can either be horizontal or vertical.

setCellFactoryback to summary
public final void setCellFactory(Callback<ListView<T>, ListCell<T>> value)

Sets a new cell factory to use by both list views. This forces all old ListCell's to be thrown away, and new ListCell's created with the new cell factory.

setOrientationback to summary
public final void setOrientation(Orientation value)

Sets the Orientation of the ListSelectionView - this can either be horizontal or vertical.

setSourceFooterback to summary
public final void setSourceFooter(Node node)

Sets the value of sourceFooterProperty().

Parameters
node:Node

the new node shown below the source list

setSourceHeaderback to summary
public final void setSourceHeader(Node node)

Sets the value of sourceHeaderProperty().

Parameters
node:Node

the new header node to use for the source list

setSourceItemsback to summary
public final void setSourceItems(ObservableList<T> value)

Sets the underlying data model for the ListView. Note that it has a generic type that must match the type of the ListView itself.

setTargetFooterback to summary
public final void setTargetFooter(Node node)

Sets the value of targetFooterProperty().

Parameters
node:Node

the new node shown below the target list

setTargetHeaderback to summary
public final void setTargetHeader(Node node)

Sets the value of targetHeaderProperty().

Parameters
node:Node

the new node shown above the target list

setTargetItemsback to summary
public final void setTargetItems(ObservableList<T> value)

Sets the underlying data model for the ListView. Note that it has a generic type that must match the type of the ListView itself.

sourceFooterPropertyback to summary
public final ObjectProperty<Node> sourceFooterProperty()

A property used to store a reference to a node that will be displayed below the source list view. The default node is a node with two buttons for easily selecting / deselecting all elements in the list view.

Returns:ObjectProperty<Node>

the property used to store the source footer node

sourceHeaderPropertyback to summary
public final ObjectProperty<Node> sourceHeaderProperty()

A property used to store a reference to a node that will be displayed above the source list view. The default node is a Label displaying the text "Available".

Returns:ObjectProperty<Node>

the property used to store the source header node

sourceItemsPropertyback to summary
public final ObjectProperty<ObservableList<T>> sourceItemsProperty()

The underlying data model for the source list view. Note that it has a generic type that must match the type of the source list view itself.

targetFooterPropertyback to summary
public final ObjectProperty<Node> targetFooterProperty()

A property used to store a reference to a node that will be displayed below the target list view. The default node is a node with two buttons for easily selecting / deselecting all elements in the list view.

Returns:ObjectProperty<Node>

the property used to store the source footer node

targetHeaderPropertyback to summary
public final ObjectProperty<Node> targetHeaderProperty()

A property used to store a reference to a node that will be displayed above the target list view. The default node is a Label displaying the text "Selected".

Returns:ObjectProperty<Node>

the property used to store the target header node

targetItemsPropertyback to summary
public final ObjectProperty<ObservableList<T>> targetItemsProperty()

The underlying data model for the target list view. Note that it has a generic type that must match the type of the source list view itself.

org.controlsfx.control back to summary

public abstract Class ListSelectionView.ListSelectionAction<T>

extends Action
Class Inheritance
Known Direct Subclasses
org.controlsfx.control.ListSelectionView.MoveToTarget, org.controlsfx.control.ListSelectionView.MoveToTargetAll, org.controlsfx.control.ListSelectionView.MoveToSource, org.controlsfx.control.ListSelectionView.MoveToSourceAll
Type Parameters
<T>
Type of ListSelectionView to which this ListSelectionAction will be added.

Specialized actions for ListSelectionView which get access to both the internal list views. A user can add a custom action to the control by extending this class and adding its instance to the action list.

Constructor Summary

AccessConstructor and Description
public
ListSelectionAction(Node
Graphic to be shown in relation to this action.
graphic
)

Creates a new instance of ListSelectionAction with the graphic node.

public
ListSelectionAction(Node
Graphic to be shown in relation to this action.
graphic
,
String
The text for the Action.
text
)

Creates a new instance of ListSelectionAction with the provided graphic and text.

Method Summary

Modifier and TypeMethod and Description
public abstract void
initialize(ListView<T>
The source list view
sourceListView
,
ListView<T>
The target list view
targetListView
)

Can be used to define properties or bindings for actions which are directly dependent on the list views.

protected final void
Inherited from org.controlsfx.control.action.Action:
acceleratorPropertydisabledPropertygetAcceleratorgetEventHandlergetGraphicgetLongTextgetPropertiesgetStylegetStyleClassgetTextgraphicPropertyhandleisDisabledisSelectedlocklongTextPropertyselectedPropertysetAcceleratorsetDisabledsetGraphicsetLongTextsetSelectedsetStylesetTextstylePropertytextProperty

Constructor Detail

ListSelectionActionback to summary
public ListSelectionAction(Node graphic)

Creates a new instance of ListSelectionAction with the graphic node.

Parameters
graphic:Node

Graphic to be shown in relation to this action.

ListSelectionActionback to summary
public ListSelectionAction(Node graphic, String text)

Creates a new instance of ListSelectionAction with the provided graphic and text.

Parameters
graphic:Node

Graphic to be shown in relation to this action.

text:String

The text for the Action.

Method Detail

initializeback to summary
public abstract void initialize(ListView<T> sourceListView, ListView<T> targetListView)

Can be used to define properties or bindings for actions which are directly dependent on the list views.

Parameters
sourceListView:ListView<T>

The source list view

targetListView:ListView<T>

The target list view

setEventHandlerback to summary
protected final void setEventHandler(Consumer<ActionEvent> eventHandler)

Overrides org.controlsfx.control.action.Action.setEventHandler.

Annotations
@Override
org.controlsfx.control back to summary

public Class ListSelectionView.MoveToSource

extends ListSelectionView.ListSelectionAction<T>
Class Inheritance

Action use to move the selected items from the target list view to the source list view.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
initialize(ListView<T> sourceListView, ListView<T> targetListView)

Implements abstract org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Can be used to define properties or bindings for actions which are directly dependent on the list views.

Inherited from org.controlsfx.control.ListSelectionView.ListSelectionAction:
setEventHandler

Constructor Detail

MoveToSourceback to summary
public MoveToSource()

Method Detail

initializeback to summary
public void initialize(ListView<T> sourceListView, ListView<T> targetListView)

Implements abstract org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Doc from org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Can be used to define properties or bindings for actions which are directly dependent on the list views.

Annotations
@Override
org.controlsfx.control back to summary

public Class ListSelectionView.MoveToSourceAll

extends ListSelectionView.ListSelectionAction<T>
Class Inheritance

Action use to all the items from the target list view to the source list view.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
initialize(ListView<T> sourceListView, ListView<T> targetListView)

Implements abstract org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Can be used to define properties or bindings for actions which are directly dependent on the list views.

Inherited from org.controlsfx.control.ListSelectionView.ListSelectionAction:
setEventHandler

Constructor Detail

MoveToSourceAllback to summary
public MoveToSourceAll()

Method Detail

initializeback to summary
public void initialize(ListView<T> sourceListView, ListView<T> targetListView)

Implements abstract org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Doc from org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Can be used to define properties or bindings for actions which are directly dependent on the list views.

Annotations
@Override
org.controlsfx.control back to summary

public Class ListSelectionView.MoveToTarget

extends ListSelectionView.ListSelectionAction<T>
Class Inheritance

Action use to move the selected items from the source list view to the target list view.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
initialize(ListView<T> sourceListView, ListView<T> targetListView)

Implements abstract org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Can be used to define properties or bindings for actions which are directly dependent on the list views.

Inherited from org.controlsfx.control.ListSelectionView.ListSelectionAction:
setEventHandler

Constructor Detail

MoveToTargetback to summary
public MoveToTarget()

Method Detail

initializeback to summary
public void initialize(ListView<T> sourceListView, ListView<T> targetListView)

Implements abstract org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Doc from org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Can be used to define properties or bindings for actions which are directly dependent on the list views.

Annotations
@Override
org.controlsfx.control back to summary

public Class ListSelectionView.MoveToTargetAll

extends ListSelectionView.ListSelectionAction<T>
Class Inheritance

Action use to move all the items from the source list view to the target list view.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
initialize(ListView<T> sourceListView, ListView<T> targetListView)

Implements abstract org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Can be used to define properties or bindings for actions which are directly dependent on the list views.

Inherited from org.controlsfx.control.ListSelectionView.ListSelectionAction:
setEventHandler

Constructor Detail

MoveToTargetAllback to summary
public MoveToTargetAll()

Method Detail

initializeback to summary
public void initialize(ListView<T> sourceListView, ListView<T> targetListView)

Implements abstract org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Doc from org.controlsfx.control.ListSelectionView.ListSelectionAction.initialize.

Can be used to define properties or bindings for actions which are directly dependent on the list views.

Annotations
@Override