Witam, po wpisaniu nazwy klasy w Controller Class w Scene Builderze wyskakuję mi błąd Exception in Application start method, konkretnie w metodzie loader.load();
Próbowałem dodać Controller w Scene Builderze, potem w Mainie za pomocą utworzenia obiektu i zawsze ten sam efekt.
Będę wdzięczny za pomoc Pozdrawiam
Mariusz1993 napisał(a):
wyskakuję mi błąd Exception in Application start method, konkretnie w metodzie loader.load();
A jaki konkretnie, Prosze Pana.
Daj kod.
Main
package org.example;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafxkurs.StackPaneController;
public class Main extends Application
{
public static void main(String[] args)
{
launch(args);
}
@Override
public void start(Stage stage) throws Exception
{
FXMLLoader fxmlLoader=new FXMLLoader();
fxmlLoader.setLocation(this.getClass().getResource("/fxml/StackPaneWindow.fxml"));
StackPaneController stackPaneController=new StackPaneController();
fxmlLoader.setController(stackPaneController);
StackPane stackPane=fxmlLoader.load();
Scene scene=new Scene(stackPane);
stage.setScene(scene);
stage.setTitle("First window");
stage.show();
}
}
Klasa StackPaneController
package javafxkurs;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
public class StackPaneController
{
@FXML
private Button newButton=new Button("FirstButton");
public StackPaneController()
{
System.out.println("Hello World!");
}
}
@FXML
private Button newButton=new Button("FirstButton");
WUT?
Albo wstrzykujesz przez loadera w polu oznaczi tym FXML albo robisz new...