#Java Help : Exception in Application constructor

1 messages · Page 1 of 1 (latest)

thick vapor
#

package yin;

import javafx.application.Platform;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class Main extends Application {
private TextField result;

@Override
public void start(Stage primaryStage) {
    try {
        GridPane root = new GridPane();
        root.setHgap(10);
        root.setVgap(10);
        root.setPadding(new Insets(0, 10, 10, 10));

    
        MenuBar menuBar = new MenuBar();
        
        Menu menuFile = new Menu("File");
        Menu menuHelp = new Menu("Help");
        menuBar.getMenus().addAll(menuFile, menuHelp);

     
        MenuItem menuNew = new MenuItem("New");
        MenuItem menuExit = new MenuItem("Exit");
        menuFile.getItems().addAll(menuNew, menuExit);

        MenuItem menuAbout = new MenuItem("About");
        menuHelp.getItems().add(menuAbout);

 
        menuAbout.setOnAction(e -> {
            Platform.runLater(() -> showAboutDialog());
        });

     
        Scene scene = new Scene(root);
        primaryStage.setScene(scene);
        primaryStage.setMinWidth(265); 
        primaryStage.setMinHeight(380); 
        primaryStage.setMaxWidth(265);
        primaryStage.setMaxHeight(380); 
        primaryStage.setTitle("GSLC 9");
        primaryStage.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}



private void showAboutDialog() {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle("About");
    alert.setHeaderText(null);
    alert.setContentText("Calculator by James\nNIM: 777");

    alert.showAndWait();
}



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

}

it says exception handling once i launched?

#

ive put my javafx though whats wrong wit it

stark mauve
#

Please include more details and format the code properly. See #📄・posting-guidelines

thick vapor
#

excuse me but

#

how do i format the code whats wrong with it

#

im still very new to java