JavaFX DatePicker create

Description

JavaFX DatePicker create

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage; 

public class Main extends Application { 
    Label bDateLbl = new Label("Birth Date:"); 

    DatePicker bDateFld = new DatePicker(); 

    public static void main(String[] args) { 
        Application.launch(args); //from  w w w.  ja v a2s .c  om
    } 

    @Override 
    public void start(Stage stage) throws Exception { 

        GridPane grid = new GridPane(); 
        grid.setHgap(5); 
        grid.setVgap(5); 

        // Place the controls in the grid     
        grid.add(bDateLbl, 0, 2);  // column=0, row=2 
        grid.add(bDateFld, 1, 2);  // column=1, row=2 

        Scene scene = new Scene(grid); 
        stage.setScene(scene); 
        stage.setTitle("Person Details"); 
        stage.sizeToScene(); 
        stage.show(); 
    } 
 
} 



PreviousNext

Related