import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.control.*;
import java.util.*;

public class HandleAction1 extends Application  
{
    public void start(Stage win) throws Exception 
    {
        win.setTitle("Handle Button Click");            //set the title for the window

        Label     title  = new Label("It is a Start");  //create a text label
        Label     label1 = new Label("Enter Name");     
        TextField field1 = new TextField( );            //create a text field
        Button    btn    = new Button("Enter");         //create a button
        Label     output = new Label();                 //area for output    
         
        GridPane pane = new GridPane( );                //create a Grid layout manager
        pane.add(title,  1, 0);                         //add components to layout manager 
        pane.add(label1, 0, 1);                         //col,row (0 based)
        pane.add(field1, 0, 2);                         
        pane.add(btn,    0, 3);
        pane.add(output, 1, 3);
        
        btn.setOnAction( event -> { String in=field1.getText();         //read data entered in field1
                                    output.setText(in);     });         //display it in output area   
                                                                                        
//or    btn.setOnAction( event -> output.setText(field1.getText()) );   //or simply together 

        Scene scene = new Scene(pane, 300, 150);        //create a scene (a screen)
        win.setScene(scene);                            //attach the scene to the stage (window)
        win.show( );                                    //display the window
    }

    public static void main(String[ ] args) 
    {
        Application.launch(args);
    }
}