Java Reference
In-Depth Information
so any Swing access should be made on the EDT. That said, a new thread is created us-
ing SwingUtilities.invokeLater , and a lambda expression encapsulates the
Runnable that is used to set the Swing content.
To learn more about using SwingNode in your applications, and to see a more
substantial example, refer to Recipe 14-18.
2-10. Adding a DatePicker
Problem
You want to add a component to your JavaFX application that will allow you to select a
calendar date.
Solution
Utilize the new JavaFX DatePicker component. In the following example, a
DatePicker component is used to select a date and display it in a label.
public class Recipe02_10 extends Application {
private Label dateLabel;
private DatePicker datePicker;
@Override
public void start(Stage primaryStage) throws
Exception {
dateLabel = new Label("Select a date using the
widget");
datePicker = new DatePicker(LocalDate.now());
datePicker.setOnAction(event -> {
dateLabel.setText("The selected date is: "
+ datePicker.getValue());
});
FlowPane flow = new FlowPane();
flow.setPadding(new Insets(5, 5, 5, 5));
Search WWH ::




Custom Search