I'm making a loan calculator for a beginner Java course. It will take input from two text fields ("loanAmount" and "loanYears") and, upon clicking a button "showTable", will generate and display a table of increasing interest rates, monthly payments and overall loan totals.
So far I've only begun constructing the program with a few of the required GUI elements. No logic has been implemented. However, I'm having trouble getting this simple stage to display any scene. In fact, the stage (window) never shows up at all. I've cross referenced my syntax and code structure with the guided exercises from our textbook, and everything seems to be in line so I'm confused what the problem could be. This project is using Java 1.7 if that matters.
import javafx.stage.Stage;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
public class LoanCalculator extends Application{
protected BorderPane getPane() {
HBox paneInputs = new HBox(50);
TextField loanAmount = new TextField();
TextField loanYears = new TextField();
Button showTable = new Button("Show Table");
paneInputs.getChildren().addAll(loanAmount, loanYears, showTable);
paneInputs.setAlignment(Pos.CENTER);
paneInputs.setStyle("-fx-border-color: green");
BorderPane pane = new BorderPane();
pane.setTop(paneInputs);
return pane;
}
@Override
public void start(Stage primaryStage) { //Builds stage
Scene scene = new Scene(getPane(), 450, 200);
primaryStage.setTitle("Loan Calculator (16.13)");
primaryStage.setScene(scene);
primaryStage.show();
}