import javafx.application.Application; import static javafx.application.Application.launch; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.geometry.NodeOrientation; import javafx.scene.Scene; import javafx.scene.control.DatePicker; import javafx.scene.control.ToggleButton; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class DatePickerWeekNumbers extends Application{ private void init(Stage primaryStage) { VBox root = new VBox(); root.setSpacing(20); Scene scene = new Scene(root, 400, 200); scene.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT); primaryStage.setScene(scene); DatePicker datePicker = new DatePicker(); ToggleButton weekNumbersButton = new ToggleButton("Show Week Numbers"); weekNumbersButton.selectedProperty().addListener(new ChangeListener() { public void changed(ObservableValue ov, Boolean t, Boolean t1) { datePicker.setShowWeekNumbers(t1); } }); root.getChildren().addAll(datePicker, weekNumbersButton); } @Override public void start(Stage primaryStage) throws Exception { init(primaryStage); primaryStage.setTitle("DatePicker Test " + System.getProperty("javafx.runtime.version")); primaryStage.show(); } public static void main(String[] args) { launch(args); } }