Top Description Fields Constructors Methods
com.dlsc.gemsfx

public Class CalendarPicker

extends CustomComboBox<LocalDate>
Class Inheritance
Imports
com.dlsc.gemsfx.skins.CalendarPickerSkin, javafx.application.Platform, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.css.PseudoClass, javafx.scene.control.Skin, .TextField, javafx.scene.input.KeyCode, .KeyEvent, javafx.scene.layout.Region, javafx.util.Callback, .StringConverter, javafx.util.converter.LocalDateStringConverter, org.apache.commons.lang3.StringUtils, java.time.LocalDate, java.util.Objects

A control for selecting a date that replaces the default javafx.scene.control.DatePicker that ships with JavaFX. The month view that the user can bring up by clicking on the button on the right-hand side of this control is an instance of CalendarView, which is more powerful than the normal view used by javafx.scene.control.DatePicker. The CalendarView allows the user to directly jump to a specific month or year.

Field Summary

Modifier and TypeField and Description
private CalendarView
private final ObjectProperty<StringConverter<LocalDate>>
private final ObjectProperty<Callback<LocalDate, Boolean>>
private final TextField

Constructor Summary

AccessConstructor and Description
public
CalendarPicker()

Constructs a new calendar picker.

Method Summary

Modifier and TypeMethod and Description
private void
private void
public final ObjectProperty<StringConverter<LocalDate>>

Returns:

the converter object
converterProperty
()

A converter used to translate a text into a YearMonth object and vice versa.

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

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

public final ObjectProperty<Callback<LocalDate, Boolean>>

Returns:

a callback that determines the selection ability of each date based on custom criteria.
dateFilterProperty
()

A property to define a filter for determining which dates in the calendar can be selected.

public CalendarView

Returns:

the calendar view for picking a date
getCalendarView
()

Returns the view used to display dates when the picker is opening up.

public final StringConverter<LocalDate>
public final Callback<LocalDate, Boolean>
public final TextField

Returns:

the editor / text field
getEditor
()

Returns the text field control used for manual input.

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 void
public final void
public final void
private void
Inherited from com.dlsc.gemsfx.CustomComboBox:
buttonDisplayPropertygetButtonDisplaygetClassCssMetaDatagetControlCssMetaDatasetButtonDisplay

Field Detail

calendarViewback to summary
private CalendarView calendarView
converterback to summary
private final ObjectProperty<StringConverter<LocalDate>> converter
dateFilterback to summary
private final ObjectProperty<Callback<LocalDate, Boolean>> dateFilter
editorback to summary
private final TextField editor

Constructor Detail

CalendarPickerback to summary
public CalendarPicker()

Constructs a new calendar picker.

Method Detail

commitValueback to summary
private void commitValue()
commitValueAndShowback to summary
private void commitValueAndShow()
converterPropertyback to summary
public final ObjectProperty<StringConverter<LocalDate>> converterProperty()

A converter used to translate a text into a YearMonth object and vice versa.

Returns:ObjectProperty<StringConverter<LocalDate>>

the converter object

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
dateFilterPropertyback to summary
public final ObjectProperty<Callback<LocalDate, Boolean>> dateFilterProperty()

A property to define a filter for determining which dates in the calendar can be selected. This filter is applied to each date displayed in the calendar. If the filter returns true for a given date, that date will be selectable (i.e., it passes the filter). If the filter returns false, the date will be disabled and cannot be selected. This property is particularly useful for scenarios where only specific dates should be available for selection based on custom logic, such as business rules, holidays, or availability.

When SelectionMode is CalendarView.SelectionModel.SelectionMode#DATE_RANGE, disabled dates can be included within the selected range. However, disabled dates cannot be used as either the starting or ending point of the range.

Returns:ObjectProperty<Callback<LocalDate, Boolean>>

a callback that determines the selection ability of each date based on custom criteria.

getCalendarViewback to summary
public CalendarView getCalendarView()

Returns the view used to display dates when the picker is opening up. This method can be overridden to return a customized version of a CalendarView.

Returns:CalendarView

the calendar view for picking a date

getConverterback to summary
public final StringConverter<LocalDate> getConverter()
getDateFilterback to summary
public final Callback<LocalDate, Boolean> getDateFilter()
getEditorback to summary
public final TextField getEditor()

Returns the text field control used for manual input.

Returns:TextField

the editor / text field

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
placeCaretAtEndback to summary
private void placeCaretAtEnd()
setConverterback to summary
public final void setConverter(StringConverter<LocalDate> converter)
setDateFilterback to summary
public final void setDateFilter(Callback<LocalDate, Boolean> dateFilter)
updateTextAndHidePopupback to summary
private void updateTextAndHidePopup()