Top Description Inners Fields Constructors Methods
org.controlsfx.control

public Class ListActionView<T>

extends ControlsFXControl
Class Inheritance
Type Parameters
<T>
Type of ListActionView.
Imports
impl.org.controlsfx.skin.ListActionViewSkin, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ObservableList, javafx.event.ActionEvent, javafx.geometry.Side, javafx.scene.Node, javafx.scene.control.Cell, .ListCell, .ListView, .Skin, javafx.util.Callback, org.controlsfx.control.action.Action, java.util.function.Consumer

A control used to perform actions on a ListView. Actions can be added by accessing the action list. These actions are represented as buttons on the control. These buttons can be moved to any side of the ListView using the sideProperty().

Screenshot

Screenshot of ListActionView

Code Example

    ListActionView view = new ListActionView<>();
    view.getItems().add("One", "Two", "Three");
    view.getActions().add(new ListActionView.ListAction() {
        {
            setGraphic(new FontAwesome().create(FontAwesome.Glyph.BOLT));
        }

       @Override
        public void initialize(ListView listView) {
            setEventHandler(e -> System.out.println("Action fired!"));
        }
    });
    view.getActions().add(ActionUtils.ACTION_SEPARATOR);

Nested and Inner Type Summary

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

Specialized actions for ListActionView which get access to the internal ListView.

Field Summary

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

Constructor Summary

AccessConstructor and Description
public

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<?>
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 shown on one of the sides of the ListView.

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

Returns the current cell factory.

public final ObservableList<T>

Returns:

An ObservableList of T.
getItems
()

The list of items for the list view.

public Side

Returns:

The current position of the action buttons in the ListActionView.
getSide
()

The current position of the action buttons in the ListActionView.

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.

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

Sets a new cell factory for the list view.

public void
setSide(Side
The side to place the action buttons.
side
)

The position to place the action buttons in this ListActionView.

public ObjectProperty<Side>
sideProperty()

The position of the action buttons in the ListActionView.

Inherited from org.controlsfx.control.ControlsFXControl:
getUserAgentStylesheet

Field Detail

actionsback to summary
private final ObservableList<Action> actions
cellFactoryback to summary
private ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactory
DEFAULT_STYLEback to summary
private static final String DEFAULT_STYLE
itemsback to summary
private final ObservableList<T> items
sideback to summary
private ObjectProperty<Side> side

Constructor Detail

ListActionViewback to summary
public ListActionView()

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<?> 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 shown on one of the sides of the ListView. 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 the internal ListView, an instance of ListAction should be used.

Returns:ObservableList<Action>

An ObservableList of actions.

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

Returns the current cell factory.

getItemsback to summary
public final ObservableList<T> getItems()

The list of items for the list view.

Returns:ObservableList<T>

An ObservableList of T.

getSideback to summary
public Side getSide()

The current position of the action buttons in the ListActionView.

Returns:Side

The current position of the action buttons in the ListActionView.

Default Value
Side#LEFT
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
setCellFactoryback to summary
public final void setCellFactory(Callback<ListView<T>, ListCell<T>> value)

Sets a new cell factory for the list view. This forces all old ListCell's to be thrown away, and new ListCell's created with the new cell factory.

setSideback to summary
public void setSide(Side side)

The position to place the action buttons in this ListActionView. Whenever this changes the ListActionView will immediately update the location of the action buttons to reflect the same.

Parameters
side:Side

The side to place the action buttons.

sidePropertyback to summary
public ObjectProperty<Side> sideProperty()

The position of the action buttons in the ListActionView.

org.controlsfx.control back to summary

public abstract Class ListActionView.ListAction<T>

extends Action
Class Inheritance
Type Parameters
<T>
Type of ListActionView to which this ListAction will be added.

Specialized actions for ListActionView which get access to the internal ListView. 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
ListAction(Node
Graphic to be shown in relation to this action.
graphic
)

Creates a new instance of ListAction with the graphic node.

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

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

Method Summary

Modifier and TypeMethod and Description
public abstract void
initialize(ListView<T>
The list view
listView
)

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

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

Constructor Detail

ListActionback to summary
public ListAction(Node graphic)

Creates a new instance of ListAction with the graphic node.

Parameters
graphic:Node

Graphic to be shown in relation to this action.

ListActionback to summary
public ListAction(Node graphic, String text)

Creates a new instance of ListAction 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> listView)

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

Parameters
listView:ListView<T>

The list view

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

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

Annotations
@Override