Top Description Inners Fields Constructors Methods
com.dlsc.showcase.impl

public Class SamplePage

extends ListView<SamplePage.SectionItem>
Class Inheritance
Imports
javafx.collections.FXCollections, .ObservableList, javafx.geometry.Orientation, .Pos, .Side, javafx.scene.Node, javafx.scene.control.*, javafx.scene.layout.HBox, .Priority, .VBox, javafx.scene.paint.Color, javafx.scene.web.HTMLEditor, java.util.HashMap, .Map, java.util.function.Supplier

Page showing every control in every state.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
private Map<SamplePage.SectionItem, Node>
private Map<String, Node>
private ObservableList<SamplePage.SectionItem>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Node
public Map<String, Node>
public ObservableList<SamplePage.SectionItem>
private void
newDetailedSection(String[] labels, Supplier<Node[]> childrenSupplier)

private void
newSection(String name, Supplier<Node[]> childrenSupplier)

private void
newSection(String name, int spacing, Supplier<Node[]> childrenSupplier)

Inherited from javafx.scene.control.ListView:
cellFactoryPropertycreateDefaultSkinediteditablePropertyeditAnyEventeditCancelEventeditCommitEventeditingIndexPropertyeditStartEventfixedCellSizePropertyfocusModelPropertygetCellFactorygetClassCssMetaDatagetControlCssMetaDatagetEditingIndexgetFixedCellSizegetFocusModelgetItemsgetOnEditCancelgetOnEditCommitgetOnEditStartgetOnScrollTogetOrientationgetPlaceholdergetSelectionModelisEditableitemsPropertyonEditCancelPropertyonEditCommitPropertyonEditStartPropertyonScrollToPropertyorientationPropertyplaceholderPropertyqueryAccessibleAttributerefreshscrollToscrollToselectionModelPropertysetCellFactorysetEditablesetFixedCellSizesetFocusModelsetItemssetOnEditCancelsetOnEditCommitsetOnEditStartsetOnScrollTosetOrientationsetPlaceholdersetSelectionModel

Field Detail

cacheback to summary
private Map<SamplePage.SectionItem, Node> cache
contentback to summary
private Map<String, Node> content
sectionItemsback to summary
private ObservableList<SamplePage.SectionItem> sectionItems

Constructor Detail

SamplePageback to summary
public SamplePage()

Method Detail

createAlertButtonback to summary
private Node createAlertButton(String title, Alert.AlertType type)
getContentback to summary
public Map<String, Node> getContent()
getSectionItemsback to summary
public ObservableList<SamplePage.SectionItem> getSectionItems()
newDetailedSectionback to summary
private void newDetailedSection(String[] labels, Supplier<Node[]> childrenSupplier)
newSectionback to summary
private void newSection(String name, Supplier<Node[]> childrenSupplier)
newSectionback to summary
private void newSection(String name, int spacing, Supplier<Node[]> childrenSupplier)
com.dlsc.showcase.impl back to summary

pack-priv Class SamplePage.SectionItem

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv Supplier<Node>
pack-priv String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

contentback to summary
pack-priv Supplier<Node> content
nameback to summary
pack-priv String name

Constructor Detail

SectionItemback to summary
pack-priv SectionItem()

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
com.dlsc.showcase.impl back to summary

pack-priv Class SamplePage.SectionListCell

extends ListCell<SamplePage.SectionItem>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private HBox
private Label

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
updateItem(SamplePage.SectionItem
The new item for the cell.
item
,
boolean
whether or not this cell represents data from the list. If it is empty, then it does not represent any domain data, but is a cell being used to render an "empty" row.
empty
)

Overrides javafx.scene.control.Cell.updateItem.

The updateItem method should not be called by developers, but it is the best method for developers to override to allow for them to customise the visuals of the cell.

Inherited from javafx.scene.control.ListCell:
cancelEditcommitEditcreateDefaultSkinexecuteAccessibleActiongetListViewlayoutChildrenlistViewPropertyqueryAccessibleAttributestartEditupdateListView

Field Detail

boxback to summary
private HBox box
nameLabelback to summary
private Label nameLabel

Constructor Detail

SectionListCellback to summary
public SectionListCell()

Method Detail

updateItemback to summary
protected void updateItem(SamplePage.SectionItem item, boolean empty)

Overrides javafx.scene.control.Cell.updateItem.

Doc from javafx.scene.control.Cell.updateItem.

The updateItem method should not be called by developers, but it is the best method for developers to override to allow for them to customise the visuals of the cell. To clarify, developers should never call this method in their code (they should leave it up to the UI control, such as the javafx.scene.control.ListView control) to call this method. However, the purpose of having the updateItem method is so that developers, when specifying custom cell factories (again, like the ListView cell factory), the updateItem method can be overridden to allow for complete customisation of the cell.

It is very important that subclasses of Cell override the updateItem method properly, as failure to do so will lead to issues such as blank cells or cells with unexpected content appearing within them. Here is an example of how to properly override the updateItem method:

protected void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);

    if (empty || item == null) {
        setText(null);
        setGraphic(null);
    } else {
        setText(item.toString());
    }
}

Note in this code sample two important points:

  1. We call the super.updateItem(T, boolean) method. If this is not done, the item and empty properties are not correctly set, and you are likely to end up with graphical issues.
  2. We test for the empty condition, and if true, we set the text and graphic properties to null. If we do not do this, it is almost guaranteed that end users will see graphical artifacts in cells unexpectedly.
Parameters
item:SamplePage.SectionItem

The new item for the cell.

empty:boolean

whether or not this cell represents data from the list. If it is empty, then it does not represent any domain data, but is a cell being used to render an "empty" row.

Annotations
@Override