Top Description Fields Constructors Methods
com.dlsc.gemsfx

public Class ChipView<T>

extends Control
Class Inheritance
Type Parameters
<T>
the model object represented by the chip
Imports
com.dlsc.gemsfx.skins.ChipViewSkin, java.util.Objects, java.util.function.Consumer, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.scene.Node, javafx.scene.control.ContentDisplay, .Control, .Skin, javafx.scene.layout.Region

A small "badge-style" view representing a model object. One usage inside GemsFX is the display of the currently active filters inside FilterView.

Field Summary

Modifier and TypeField and Description
private final ObjectProperty<ContentDisplay>
private final ObjectProperty<Node>
private final ObjectProperty<Consumer<T>>
private final StringProperty
private final ObjectProperty<T>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<ContentDisplay>

Returns:

the content display value
contentDisplayProperty
()

The content display property of the chip will be bound to the same property of the label used by the chip's skin.

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

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

public final ContentDisplay
public final Node
public final Consumer<T>
public final String

Returns:

the chip view's text
getText
()

The text shown by the view.

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 T
public final ObjectProperty<Node>

Returns:

the chip view's graphic
graphicProperty
()

The graphic node shown by the chip view.

public final ObjectProperty<Consumer<T>>

Returns:

the on-close consumer
onCloseProperty
()

A callback consumer that will be invoked when the user clicks on the close icon of the chip.

public final void
public final void
setGraphic(Node graphic)

public final void
setOnClose(Consumer<T> onClose)

public final void
public final void
setValue(T value)

public final StringProperty
public final ObjectProperty<T>

Returns:

the value of the view
valueProperty
()

The value / model object represented by the chip view.

Inherited from javafx.scene.control.Control:
computeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcontextMenuPropertyexecuteAccessibleActiongetBaselineOffsetgetClassCssMetaDatagetContextMenugetControlCssMetaDatagetCssMetaDatagetInitialFocusTraversablegetSkingetTooltipisResizablelayoutChildrenqueryAccessibleAttributesetContextMenusetSkinsetTooltipskinPropertytooltipProperty

Field Detail

contentDisplayback to summary
private final ObjectProperty<ContentDisplay> contentDisplay
graphicback to summary
private final ObjectProperty<Node> graphic
onCloseback to summary
private final ObjectProperty<Consumer<T>> onClose
textback to summary
private final StringProperty text
valueback to summary
private final ObjectProperty<T> value

Constructor Detail

ChipViewback to summary
public ChipView()

Method Detail

contentDisplayPropertyback to summary
public final ObjectProperty<ContentDisplay> contentDisplayProperty()

The content display property of the chip will be bound to the same property of the label used by the chip's skin. This property allows applications to switch to a "graphics only" mode (see ContentDisplay#GRAPHIC_ONLY).

Returns:ObjectProperty<ContentDisplay>

the content display value

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
getContentDisplayback to summary
public final ContentDisplay getContentDisplay()
getGraphicback to summary
public final Node getGraphic()
getOnCloseback to summary
public final Consumer<T> getOnClose()
getTextback to summary
public final String getText()

The text shown by the view.

Returns:String

the chip view's text

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
getValueback to summary
public final T getValue()
graphicPropertyback to summary
public final ObjectProperty<Node> graphicProperty()

The graphic node shown by the chip view.

Returns:ObjectProperty<Node>

the chip view's graphic

onClosePropertyback to summary
public final ObjectProperty<Consumer<T>> onCloseProperty()

A callback consumer that will be invoked when the user clicks on the close icon of the chip. Applications can use this property / consumer to update the UI as a result of the closing.

Returns:ObjectProperty<Consumer<T>>

the on-close consumer

setContentDisplayback to summary
public final void setContentDisplay(ContentDisplay contentDisplay)
setGraphicback to summary
public final void setGraphic(Node graphic)
setOnCloseback to summary
public final void setOnClose(Consumer<T> onClose)
setTextback to summary
public final void setText(String text)
setValueback to summary
public final void setValue(T value)
textPropertyback to summary
public final StringProperty textProperty()
valuePropertyback to summary
public final ObjectProperty<T> valueProperty()

The value / model object represented by the chip view.

Returns:ObjectProperty<T>

the value of the view