Ultra Geile Studenten Benutzer Oberfläche (UGSBO)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.3 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package com.ugsbo.gui;
  2. import java.io.IOException;
  3. import javafx.application.Application;
  4. import javafx.fxml.FXMLLoader;
  5. import javafx.scene.*;
  6. import javafx.stage.Stage;
  7. /**
  8. * Runs the main Application and handles the loading of an FXML file.
  9. */
  10. public class MainApp extends Application {
  11. /**
  12. * The main() method is ignored in correctly deployed JavaFX application. main()
  13. * serves only as fallback in case the application can not be launched through
  14. * deployment artifacts, e.g., in IDEs with limited FX support. NetBeans ignores
  15. * main().
  16. *
  17. * @param args the command line arguments
  18. */
  19. public static void main(String[] args) {
  20. launch(args);
  21. }
  22. /**
  23. * Starts the Main GUI, will be called from JavaFx.
  24. */
  25. @Override
  26. public void start(Stage stage) {
  27. createStageFromFXML(stage, "BasicGui");
  28. }
  29. /**
  30. * Loades the FXML file and the Default CSS.
  31. *
  32. * @param stage The Stage will be passed over from JavaFx
  33. * @param fxmlFileName Only the Filename of the fxml file wich sould be loaded
  34. */
  35. private void createStageFromFXML(Stage stage, String fxmlFileName) {
  36. // Gettring the FXML loader to load the File.
  37. FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFileName + ".fxml"));
  38. Parent root;
  39. // trying to load the FXML and CSS file for the GUI with the fxmlFileName.
  40. try {
  41. root = loader.load();
  42. Scene basicGUI = new Scene(root);
  43. basicGUI.getStylesheets().add(getClass().getResource("styles.css").toExternalForm());
  44. // Setting the Title of the
  45. stage.setTitle("Ultra geile Studenten Benutzeroberfläche");
  46. // set Resizeable to false, in oder to block resizeing though the User.
  47. stage.setResizable(false);
  48. stage.setScene(basicGUI);
  49. } catch (IOException e) {
  50. System.out.println(".FXML or .css File can not be found.");
  51. e.printStackTrace();
  52. }
  53. stage.show();
  54. }
  55. public static void startVokabelKartenSchreiber(){
  56. Stage stage = new Stage();
  57. MainApp main = new MainApp();
  58. main.createStageFromFXML(stage, "Voabelkartenschreiber");
  59. }
  60. /**
  61. * Startet eine Instanz der MatrixCalcGui.
  62. */
  63. public static void startMatrixCalcGUI() {
  64. Stage stage = new Stage();
  65. MainApp app = new MainApp();
  66. app.createStageFromFXML(stage, "matrixCalcGui");
  67. }
  68. }