Is that possible to display a calendar controller from scene builder? I am trying to display a calendar which ideally has to be linked to a data property and time slot. Any help?
Asked
Active
Viewed 2,842 times
1 Answers
1
I'm not using scene builder, but you can manually edit your fxml to add a DatePicker. I created a simple example that shows a date picker and when the date is chosen it displays it in a Text field below.
The fxml looks like:
<GridPane fx:controller="datepicker.DatePickerController" xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
<padding>
<Insets top="25" right="25" bottom="10" left="25" />
</padding>
<DatePicker fx:id="datepicker" GridPane.columnIndex="0" GridPane.rowIndex="0" onAction="#handleDatePickerAction"></DatePicker>
<Text fx:id="actiontarget" GridPane.columnIndex="0" GridPane.rowIndex="1" />
</GridPane>
And the controller looks like:
public class DatePickerController
{
@FXML
private Text actiontarget;
@FXML
private DatePicker datepicker;
@FXML
protected void handleDatePickerAction(ActionEvent event)
{
actiontarget.setText(datepicker.getValue().toString());
}
}

Amber
- 2,413
- 1
- 15
- 20