Previously that was my code:
import java.io.FileNotFoundException;
public class Bundesliga extends Application {
public static void main(String[] args) throws FileNotFoundException {
PlayerManager league = new PlayerManager();
league.uruchom();
}
}
Of course there is another class PlayerManager but I think it isn't needed. Everything worked very well and there were no errors. Then I tried to modify it using Javafx. There is a modified one:
import java.io.FileNotFoundException;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class Bundesliga extends Application {
Stage window;
Scene scene1;
public static void main(String[] args) throws FileNotFoundException {
launch(args);
}
@Override
public void start(Stage primaryStage) throws FileNotFoundException {
PlayerManager league = new PlayerManager();
window = primaryStage;
Button button1 = new Button("Uruchom program");
button1.setOnAction(e -> league.uruchom());
StackPane layout = new StackPane();
layout.getChildren().add(button1);
scene1 = new Scene(layout, 600, 300);
window.setScene(scene1);
window.setTitle("Title here");
window.show();
}
}
I wanted to run my code by clicking on button, but when I'm trying to compile it, the error occours: "Bundesliga.java:24: error: unreported exception FileNotFoundException; must be caught or declared to be thrown button1.setOnAction(e -> league.uruchom()); I don't know how to solve that, because my methods throw FileNotFoundException. Please help me.