created Class Factory and refactoring of MainWindow.java
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package ch.zhaw.projekt2.turnierverwaltung;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Border;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
public class Factory {
|
||||
private Tournament tournament;
|
||||
|
||||
|
||||
public Factory(){
|
||||
|
||||
}
|
||||
|
||||
public Tournament getTournament() {
|
||||
return tournament;
|
||||
}
|
||||
|
||||
public void setTournament(Tournament tournament) {
|
||||
this.tournament = tournament;
|
||||
}
|
||||
|
||||
public BorderPane loadMainWindow(){
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("mainWindow.fxml"));
|
||||
try {
|
||||
return loader.load();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
//TODO handle and logging
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void loadTournamentList(BorderPane pane){
|
||||
setCenterOfBorderPane(pane, getClass().getResource("tournamentList/tournamentList.fxml"));
|
||||
}
|
||||
|
||||
//Can be used to Open new Scene in same Stage.
|
||||
//This way possible to later give object to Controller
|
||||
public void loadParticipantFormular(BorderPane pane) {
|
||||
setCenterOfBorderPane(pane, getClass().getResource("participantAddFormular/participantFormular.fxml"));
|
||||
}
|
||||
|
||||
private void setCenterOfBorderPane(BorderPane pane, URL location) {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(location);
|
||||
pane.setCenter(loader.load());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
//TODO handle and logging?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package ch.zhaw.projekt2.turnierverwaltung.main;
|
||||
|
||||
import ch.zhaw.projekt2.turnierverwaltung.Factory;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
@@ -11,36 +12,21 @@ import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MainWindow extends Application {
|
||||
private Factory factory = new Factory(); //TODO make it private!
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("mainWindow.fxml"));
|
||||
BorderPane pane = loader.load();
|
||||
BorderPane pane = factory.loadMainWindow();
|
||||
factory.loadTournamentList(pane);
|
||||
|
||||
//test add center pane
|
||||
loader = new FXMLLoader(getClass().getResource("tournamentList/tournamentList.fxml"));
|
||||
pane.setCenter(loader.load());
|
||||
|
||||
Scene scene = new Scene(pane);
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setMaximized(true);
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.setFullScreen(false);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
//Can be used to Open new Scene in same Stage.
|
||||
//This way possible to later give object to Controller
|
||||
public void startParticipand(Stage stage) {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("participandAddFormular/participandFormular.fxml"));
|
||||
try {
|
||||
Pane pane = loader.load();
|
||||
Scene scene = new Scene(pane);
|
||||
stage.setScene(scene);
|
||||
stage.setFullScreen(true);
|
||||
stage.setResizable(false);
|
||||
stage.show();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ch.zhaw.projekt2.turnierverwaltung.main.participandAddFormular;
|
||||
package ch.zhaw.projekt2.turnierverwaltung.main.participantAddFormular;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package ch.zhaw.projekt2.turnierverwaltung.main.tournamentList;
|
||||
|
||||
import ch.zhaw.projekt2.turnierverwaltung.main.MainWindow;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
@@ -43,7 +44,7 @@ public class tournamentListController {
|
||||
}
|
||||
|
||||
@FXML
|
||||
void openTournier(ActionEvent event) {
|
||||
void openTournament(ActionEvent event) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<HBox alignment="CENTER" VBox.vgrow="ALWAYS" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.projekt2.turnierverwaltung.main.participandAddFormular.participantFormularController">
|
||||
<HBox alignment="CENTER" VBox.vgrow="ALWAYS" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.projekt2.turnierverwaltung.main.participantAddFormular.participantFormularController">
|
||||
<children>
|
||||
<VBox alignment="TOP_CENTER" prefHeight="331.0" prefWidth="308.0" HBox.hgrow="ALWAYS">
|
||||
<children>
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
<Insets />
|
||||
</VBox.margin>
|
||||
</ListView>
|
||||
<Button fx:id="openBtn" mnemonicParsing="false" onAction="#openTournier" text="Öffnen">
|
||||
<Button fx:id="openBtn" mnemonicParsing="false" onAction="#openTournament" text="Öffnen">
|
||||
<VBox.margin>
|
||||
<Insets bottom="20.0" top="40.0" />
|
||||
</VBox.margin>
|
||||
Reference in New Issue
Block a user