/*
  Write a program that displays a text file in a text area. The user enters a
  file name in a text field and clicks the View button; the file is then
  displayed in a text area.
*/

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.BorderPane;
import javafx.scene.control.TextArea;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.Button;
import java.io.File;
import java.util.Scanner;

public class E16_10 extends Application {
  @Override
  public void start(Stage primaryStage) {
    TextArea textArea = new TextArea();
    ScrollPane scrollPane = new ScrollPane(textArea);

    Label lbFileName = new Label("Filename:");
    TextField tfFileName = new TextField();
    Button btView = new Button("View");

    HBox controlPane = new HBox();
    controlPane.getChildren().addAll(lbFileName, tfFileName, btView);

    BorderPane pane = new BorderPane();
    pane.setCenter(scrollPane);
    pane.setBottom(controlPane);

    btView.setOnAction(e -> {
      File file = new File(tfFileName.getText());

      try (
        Scanner input = new Scanner(file);
      ) {
        StringBuilder sb = new StringBuilder();
        while (input.hasNext()) {
          sb.append(input.nextLine() + "\n");
        }
        textArea.setText(sb.toString());
      } catch (Exception ex) {
        textArea.setText(ex.toString());
      }
    });

    Scene scene = new Scene(pane);
    primaryStage.setTitle("E16_10");
    primaryStage.setScene(scene);
    primaryStage.show();
  }

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

@@ -547,16 +547,65 @@
 java
-.io.File
+fx.geometry.Pos;%0Aimport java.io.File;%0Aimport java.net.URI
 ;%0Aim
@@ -1204,53 +1204,219 @@
     
-File file = new File(tfFileName.getText());%0A%0A
+try %7B%0A        URI uri = new URI(tfFileName.getText());%0A        File file;%0A        if (uri.isAbsolute()) %7B%0A          file = new File(uri);%0A        %7D else %7B%0A          file = new File(uri.toString());%0A        %7D%0A%0A  
     
@@ -1423,16 +1423,18 @@
   try (%0A
+  
         
@@ -1474,20 +1474,24 @@
 ;%0A      
+  
 ) %7B%0A
+  
         
@@ -1538,16 +1538,18 @@
         
+ 
+ 
 while (i
@@ -1562,24 +1562,26 @@
 asNext()) %7B%0A
+  
           sb
@@ -1618,26 +1618,30 @@
 %22);%0A        
+ 
+ 
 %7D%0A
+  
         text
@@ -1665,24 +1665,110 @@
 oString());%0A
+        %7D catch (Exception ex) %7B%0A          textArea.setText(ex.toString());%0A        %7D%0A
       %7D catc
@@ -1972,11 +1972,81 @@
 ge.s
-how
+etResizable(false);%0A    primaryStage.show();%0A%0A    tfFileName.requestFocus
 ();%0A

Use URI to allow for both absolute and relative path entries, and make the stage not resizable