I would like to display a data from .txt report file using JavaFX. In my code, I'm trying to use Labels and Vbox to display the info in multiple formats in a GUI to scene. However, I'm having terrible outputting my results as GUI instead of the console. I tried to research my issue but I couldn't find the piece of info that I need to solve the problem.
This is the report I need to display as a GUI Application using JavaFX:
This is what my code displays as a GUI:
Here is my source code:
package sample;
public class CustomerSale {
    // Details of reports
    private String zipCodeExtension;
    private int customerNumber;
    private String customerName;
    private int purchaseDate;
    private String make;
    private int purchasePrice;
    private int yearOfVehicle;
    private int satisfactionRating;
    // Create constructor argument
    public CustomerSale(String zipCodeExtension, int customerNumber, String customerName,
                        int purchaseDate, String make, int purchasePrice,
                        int yearOfVehicle, int satisfactionRating) {
        this.zipCodeExtension = zipCodeExtension;
        this.customerNumber = customerNumber;
        this.customerName = customerName;
        this.purchaseDate = purchaseDate;
        this.make = make;
        this.purchasePrice = purchasePrice;
        this.yearOfVehicle = yearOfVehicle;
        this.satisfactionRating = satisfactionRating;
    }
    // Create getters and setters
    public String getMake() {
        return make;
    }
    public String getZipCodeExtension() {
        return zipCodeExtension;
    }
    public int getCustomerNumber() {
        return customerNumber;
    }
    public String getCustomerName() {
        return customerName;
    }
    public int getPurchaseDate() {
        return purchaseDate;
    }
    public double getPurchasePrice() {
        return purchasePrice;
    }
    public int getYearOfVehicle() {
        return yearOfVehicle;
    }
    public int getSatisfactionRating() {
        return satisfactionRating;
    }
}
package sample;
import java.io.FileNotFoundException;
import java.text.DecimalFormat;
import java.util.Scanner;
import java.io.File;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.control.Label;
import javafx.geometry.Pos;
import javafx.geometry.Insets;
/**
 ABC used cars report Application
 */
public class FinalGUIOutput extends Application {
    final int WINDOW_WIDTH = 750, // Window width in pixels
              WINDOW_HEIGHT = 150; // Window height in pixels
    public static void main(String[] args) {
        // Launch the application
        launch(args);
    }
    @Override
    public void start(Stage primaryStage) throws FileNotFoundException {
        // Create a Label to display the heading and page number.
        Label headingLabel = new Label("---------------------------------------------------------ABC USED CARS--------------------------------------------------------");
        Label pageNumber = new Label(
                "-------------------------------------------------------PAGE 1-----------------------------------------------------------------");
//        Label pageFormat = new Label("%-19s%-15s%-21s%-15s%-20s%-17s%-12s%-20s\n", "|ZIP CODE-EXT|", "|CUST No.|", "|CUSTOMER NAME|", "|DoP|",
//                "|MAKE|", "|PRICE|", "|YEAR|", "|RATE|");
        Label pageLine = new Label(
                "------------------------------------------------------------------------------------------------------------------------------");
        // Create an empty Label to display the result.
        Label resultLabel = new Label();
        File carsInfo = new File("custsale.txt");
        Scanner carsScanner = new Scanner(carsInfo);
        String format = "%-20s%-14s%-21s%-16s%-19s$%-17s%-14s%-20s\n";
        final int pageSize = 30;
        int carCounter = 0;
        while (carsScanner.hasNextLine()) {
            if (carCounter % pageSize == 0) {
                printPageHeader(carCounter / pageSize + 1);
            }
            // Read the carsScanner
            String zipCodeExtension = carsScanner.nextLine();
            int customerNumber = Integer.parseInt(carsScanner.nextLine());
            String customerName = carsScanner.nextLine();
            int purchaseDate = Integer.parseInt(carsScanner.nextLine());
            String make = carsScanner.nextLine();
            int purchasePrice = Integer.parseInt(carsScanner.nextLine());
            int yearOfVehicle = Integer.parseInt(carsScanner.nextLine());
            int satisfactionRating = Integer.parseInt(carsScanner.nextLine());
            CustomerSale custsale = new CustomerSale(zipCodeExtension, customerNumber, customerName,
                    purchaseDate, make, purchasePrice, yearOfVehicle, satisfactionRating);
            // Display the report
            DecimalFormat df = new DecimalFormat("#,#####");
            System.out.printf(format, custsale.getZipCodeExtension(), custsale.getCustomerNumber(),
                    custsale.getCustomerName(), custsale.getPurchaseDate(), custsale.getMake(),
                    df.format(custsale.getPurchasePrice()), custsale.getYearOfVehicle(),
                    custsale.getSatisfactionRating());
            // Increment the car counter
            carCounter++;
        }
        carsScanner.close();
        /**
            GUI Display
         */
        // Put the HBox, calcButton and resultLabel in a VBox.
        VBox vbox = new VBox(10,headingLabel, pageNumber, pageLine, resultLabel);
        // Set the VBox's alignment to center.
        vbox.setAlignment(Pos.CENTER);
        // Set the VBox's padding to 10 pixels
        vbox.setPadding(new Insets(10));
        // Create a Scene with the VBox as its root node.
        Scene scene = new Scene(vbox, WINDOW_WIDTH, WINDOW_HEIGHT);
        // set the scene's alignment to center.
        vbox.setAlignment(Pos.CENTER);
        //Add the Scene to the Stage
        primaryStage.setScene(scene);
        // Set the stage title
        primaryStage.setTitle("ABC Used Cars");
        // Show the window
        primaryStage.show();
    }
    private static void printPageHeader(int i) {
        // Create a Label to display the heading and page number.
        Label headingLabel = new Label("---------------------------------------------------------ABC USED CARS--------------------------------------------------------");
        Label pageNumber = new Label(
                "-------------------------------------------------------" + "PAGE " + i + "-----------------------------------------------------------------");
//        Label pageFormat = new Label("%-19s%-15s%-21s%-15s%-20s%-17s%-12s%-20s\n", "|ZIP CODE-EXT|", "|CUST No.|", "|CUSTOMER NAME|", "|DoP|",
//                "|MAKE|", "|PRICE|", "|YEAR|", "|RATE|");
        Label pageLine = new Label(
                "------------------------------------------------------------------------------------------------------------------------------");
    }
}
And finally here's my .txt file report that I'm trying to pull data from:
46410-1234
1001
ALBERT, CARL T.
08252001
FORD
0255000
1991
2
46307-1201
1003
ANDREWS, ROBERT
08262001
CHEVROLET
0700000
1958
0
46423-2311
1008
ANZIO, RAFELINO
09012001
CHEVROLET
0456050
1978
0
46424-0121
1010
ASHLEY, WILLIAM B.
09022001
PIERCE-ARROW
1240000
1932
2
46375-3110
1015
ATKINSON, MARK
08272001
STUDEBAKER
0050000
1958
1
46405-1291
1025
AVERY, ALFRED A.
08292001
HUDSON
0230000
1954
1
46301-1234
1031
BEZZMEK, JENNIFER
08272001
FORD
0455000
1995
2
46303-1201
1033
BLAKE, DONALD
08292001
FORD
0722050
1989
1
46413-2311
1041
BLONDELL, BONNIE
09042001
CHEVROLET
0356050
1988
1
46404-0121
1045
BONADIO, JAMES
09032001
PIERCE-ARROW
1150000
1935
2
46307-3110
1055
BUCKO, ONIEDA
08282001
STUDEBAKER
0245000
1964
1
46410-1291
1056
BYMANN, FREDRICK
08292001
FORD
0330000
1994
1
46342-1234
1061
CALBERT, RONALD
09052001
FORD
0355000
1993
2
46307-1211
1063
CHELSEA, MARTHA S.
08302001
DODGE BROS.
0350000
1935
0
46410-2311
1067
CLAFLIN, WAYNE R.
09012001
CHEVROLET
0456050
1990
2
46410-0121
1070
COLE, CHARLES C.
09022001
PIERCE-ARROW
1050000
1929
2
46305-3111
1075
COLEMAN, THOMAS
08272001
STUDEBAKER
0167050
1961
1
46410-1221
1076
COLWELL, RICHARD L.
08292001
HUDSON
0430000
1940
1
46414-1231
1080
COOPER, JOHNATHAN
09052001
FORD
1256000
1996
2
46307-1201
2002
COREY, SARAH D.
08272001
CHEVROLET
0650050
1994
0
46421-2311
2004
CRACKLIN, GOODMAN
09012001
CHEVROLET
1456050
1996
0
46323-0121
2011
CRAWFORD, TIMOTHY
09012001
PIERCE-ARROW
1040000
1931
2
46315-3110
2012
CURRIE, RAYMOND
08282001
STUDEBAKER
0150025
1956
1
46425-1291
2024
CYBORG, IZORE M.
09052001
HUDSON
0130000
1949
1
46410-1234
2031
DALTON, DAVID P.
08252001
FORD
0234000
1990
2
46307-1201
2043
DAVIES, RALPH O.
08262001
CHEVROLET
0333000
1989
0
46423-2311
2048
DENNICK, DONNA
09012001
CHEVROLET
0656025
1995
0
46424-0121
2050
DERBIN, DEANNA
09022001
PIERCE-ARROW
1640025
1937
2
46375-3110
2065
DONNEHUE, PHILLIP
09042001
STUDEBAKER
0054000
1966
1
46405-1291
2085
DOPPLER, RADAR O.
08302001
HUDSON
0311000
1951
1
46310-1234
2091
DUNLOP, RITA
08252001
FORD
1450045
1996
2
46303-1201
3003
DYKES, CYNTHIA
08262001
FORD
0410050
1987
1
46413-2311
3011
EATON, ESTER B.
09012001
CHEVROLET
1356050
1996
0
46404-0121
3015
EFFLEY, BAILY
09022001
PIERCE-ARROW
1446045
1933
2
46307-3110
3025
EGGERTON, AMANDA
08292001
STUDEBAKER
0335000
1965
1
46410-1291
3026
EPPLEY, DAVID
08282001
FORD
0414000
1995
1
46342-1234
3031
ERKLE, ROSA
09032001
FORD
0355020
1993
2
46307-1211
3043
FARNSWORTH, WESLEY
09052001
DODGE BROS.
1150000
1996
0
46410-2311
3047
FLANNERY, JAMES
09012001
CHEVROLET
0450050
1992
0
46410-0121
3050
FOREMAN, OTTO J.
09022001
PIERCE-ARROW
0940000
1927
2
46305-3111
3055
FOWLER, KATHLEEN
08272001
STUDEBAKER
0267050
1964
1
46410-1221
3056
FURNACE, DAVID
08292001
HUDSON
0530000
1948
1
46414-1231
3061
GALLAGHER, CLARENCE
09042001
FORD
1006000
1992
2
46307-1201
3062
GENNERRO, TONY S.
08302001
CHEVROLET
0320050
1989
0
46421-2311
3066
GOEBEL, NANCY K.
09022001
CHEVROLET
0643050
1990
0
46323-0121
3072
GUNTHER, FREDERICK
09032001
PIERCE-ARROW
1260000
1930
2
46315-3110
3080
HAINES, MARSHALL
08292001
STUDEBAKER
02500251
959
1
46425-1291
3094
HANCOCK, JONATHON
09032001
HUDSON
0330000
1953
1
46423-2311
3098
HARTNETT, ROBERTO
09052001
CHEVROLET
0326040
1988
0
46424-0121
4005
HENNING, SONIA
09052001
PIERCE-ARROW
1305000
1928
2
46375-3110
4009
HORNSBY, ROGERS
08252001
STUDEBAKER
0167500
1962
1
46405-1291
4012
HYATT, JANET F.
08302001
HUDSON
0155000
1951
1
46301-1234
4021
IDZIOR, RAYMOND
09012001
FORD
1460000
1996
2
46303-1201
4022
JENNINGS, WILLIAM
08262001
FORD
0612040
1992
1
46410-2311
4024
JOHNSON, JACK
09032001
CHEVROLET
0256050
1985
0
46404-0121
4032
KULKA, ROBERT C.
09042001
PIERCE-ARROW
0970000
1934
2
46307-3110
4035
KURTZ, DONALD
08302001
STUDEBAKER
0345000
1966
1
46410-1291
4038
LEVANDOWSKI, JILL
08282001
DODGE BROS.
0430000
1988
1
46342-1234
4044
METZ, ARNOLD E.
09012001
FORD
1323000
1996
2
46307-1211
4046
NORRIS, CHARLES S.
09052001
CHEVROLET
0844000
1992
0
46410-2311
4047
NOWAKOWSKI, ALFRED
09012001
DODGE BROS.
0656050
1994
1
46410-0121
4053
O'BOYLE, NIEL
09032001
PIERCE-ARROW
1550000
1938
2
46305-3111
4056
O'BRIAN, PATRICK
08302001
STUDEBAKER
0347050
1962
1
46410-1221
4059
PATTERSON, LENNI R.
08292001
HUDSON
0250000
1946
1
46414-1231
4061
PERRY, SHAMUS
09052001
FORD
0895000
1994
2
46307-1201
4066
REED, ROBERT B.
08272001
CHEVROLET
0740050
1996
0
46421-2311
4067
RODRIGUEZ, ALONZO
09052001
DODGE BROS.
1050050
1995
0
46323-0121
4073
SANCHEZ, HENRY
09012001
PIERCE-ARROW
0830000
1925
2
46315-3110
4081
SWARTZ, HECTOR
08282001
STUDEBAKER
0075025
1954
1
46301-1234
4084
TORREZ, MARTIN
08272001
FORD
0565000
1994
2
46303-1201
4090
TUTTLE, MARK
08292001
FORD
0710050
1996
1
46413-2311
4094
WARNER, JACK
09042001
CHEVROLET
0856050
1996
0
46404-0121
4115
YACKLEY, YOURTO
09042001
PIERCE-ARROW
1000000
1930
2
Thank you.


 
    
