created Abstract Class FXController.java

This commit is contained in:
schrom01 2022-04-29 17:30:26 +02:00
parent 9c7d62b260
commit 7af48449e0
5 changed files with 27 additions and 3 deletions

View File

@ -0,0 +1,19 @@
package ch.zhaw.projekt2.turnierverwaltung;
public abstract class FXController {
Tournament tournament;
Factory factory;
public void setup(Tournament tournament, Factory factory){
this.tournament = tournament;
this.factory = factory;
}
protected Tournament getTournament() {
return tournament;
}
protected Factory getFactory() {
return factory;
}
}

View File

@ -51,6 +51,8 @@ public class Factory {
try {
FXMLLoader loader = new FXMLLoader(location);
pane.setCenter(loader.load());
FXController controller = loader.getController();
controller.setup(tournament, this);
} catch (IOException e) {
e.printStackTrace();
//TODO handle and logging?

View File

@ -1,9 +1,10 @@
package ch.zhaw.projekt2.turnierverwaltung.main;
import ch.zhaw.projekt2.turnierverwaltung.FXController;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
public class MainWindowController {
public class MainWindowController extends FXController {
@FXML
void changeLangToGerman(ActionEvent event) {

View File

@ -1,5 +1,6 @@
package ch.zhaw.projekt2.turnierverwaltung.main.participantAddFormular;
import ch.zhaw.projekt2.turnierverwaltung.FXController;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
@ -10,7 +11,7 @@ import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
public class participantFormularController {
public class participantFormularController extends FXController {
@FXML
private Button addBtn;

View File

@ -1,5 +1,6 @@
package ch.zhaw.projekt2.turnierverwaltung.main.tournamentList;
import ch.zhaw.projekt2.turnierverwaltung.FXController;
import ch.zhaw.projekt2.turnierverwaltung.main.MainWindow;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
@ -9,7 +10,7 @@ import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.layout.GridPane;
public class tournamentListController {
public class tournamentListController extends FXController {
@FXML
private Button createBtn;