Netbeans 9 0 Java FX 10

522 Views Asked by At

Try creating a JavaFX application. Don't add or modify any code. Run the Project. It does not find the MAIN. If you run the File, then it works.

However, create JavaFX FXML application. As mentioned earlier, don't make any change to the code.

Run the Package.... it WORKS.

Does anyone know why? I tried to report the problem, but that looked more complicated than writing the code. :)

I am enclosing generated code for a JAVAFX APPLICATION

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package forsubmission;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 *
 * @author Hornigold
 */
public class ForSubmission extends Application {

    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });

        StackPane root = new StackPane();
        root.getChildren().add(btn);

        Scene scene = new Scene(root, 300, 250);

        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}

Thanks, Gold

0

There are 0 best solutions below