Esempio n. 1
0
  private void start(Stage primaryStage) throws Exception {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("main.fxml"));
    ConsoleMasterController.setMainController(new MainController());
    ConsoleMasterController.getMainController()
        .setMenuManager(
            new MyMenuBar()); // <--this method should actually be used by the launcher before
                              // calling launch() method.
    loader.setController(ConsoleMasterController.getMainController());
    AnchorPane root = loader.load();

    primaryStage.setTitle(
        AppConfiguration.Configs.NAME.getValue()
            + " "
            + AppConfiguration.Configs.VERSION.getValue());
    primaryStage.setScene(
        new Scene(
            root,
            Double.parseDouble(
                AppConfiguration.Configs.WINDOW_WIDTH.getValue()), // this looks f@#ing ugly!!!
            Double.parseDouble(AppConfiguration.Configs.WINDOW_HEIGHT.getValue())));
    primaryStage.setResizable(Boolean.valueOf(AppConfiguration.Configs.RESIZABLE.getValue()));

    primaryStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent event) {
            exitEvent();
          }
        });
    primaryStage.show();
    System.out.println(LOG + "controlStation stage created");
  }
  /**
   * Switches scenes
   *
   * @param fxml
   * @param obj
   * @throws Exception
   */
  public static void replaceSceneContent(String fxml, Object obj) throws Exception {

    FXMLLoader loader = new FXMLLoader();

    try {

      loader = new FXMLLoader(SpaceTraderMain.class.getResource(fxml));
    } catch (Exception e) {

    }
    try {
      loader.setController(obj);

    } catch (Exception e) {
      System.out.println(e);
    }
    Parent page;
    page = (Parent) loader.load();

    Scene scene;
    scene = mystage.getScene();

    if (scene == null) {
      scene = new Scene(page, 700, 450);
      // scene.getStylesheets().add(SpaceTraderMain.class.getResource("demo.css").toExternalForm());
      mystage.setScene(scene);
    } else {
      mystage.getScene().setRoot(page);
    }
    mystage.sizeToScene();

    // return page;

  }
Esempio n. 3
0
 protected void initUI(
     String stageTitle,
     String gui,
     double stageWidth,
     double stageHeight,
     double maxStageWidth,
     double maxStageHeight,
     double stageX,
     double stageY,
     boolean resizable,
     Modality modality,
     Stage stage,
     Window owner)
     throws IOException {
   FXMLLoader loader = new FXMLLoader(getClass().getResource(gui));
   loader.setController(this);
   this.scene = new Scene(loader.load(), stageWidth, stageHeight);
   this.stage = (null != stage) ? stage : new Stage();
   this.stage.setMaxWidth(maxStageWidth);
   this.stage.setMaxHeight(maxStageHeight);
   this.stage.setTitle(stageTitle);
   this.stage.setScene(this.scene);
   this.stage.setX(stageX);
   this.stage.setY(stageY);
   this.stage.resizableProperty().setValue(resizable);
   if (null != modality) this.stage.initModality(modality);
   if (null != owner) this.stage.initOwner(owner);
 }
Esempio n. 4
0
  public Notification(Stage stage, int type, String message) {
    try {
      FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Notification.fxml"));
      fxmlLoader.setController(this);
      vbox = (VBox) fxmlLoader.load();
    } catch (IOException e) {
      e.printStackTrace();
    }

    if (type == INFO) {
      fxLabelTitle.setText("Information");
      fxImageViewLogo.setImage(
          new Image(vbox.getClass().getResource(IMAGE_DIRECTORY + "info.png").toExternalForm()));
    } else if (type == SUCCESS) {
      fxLabelTitle.setText("Success");
      fxImageViewLogo.setImage(
          new Image(vbox.getClass().getResource(IMAGE_DIRECTORY + "success.png").toExternalForm()));
    } else if (type == WARNING) {
      fxLabelTitle.setText("Warning");
      fxImageViewLogo.setImage(
          new Image(vbox.getClass().getResource(IMAGE_DIRECTORY + "warning.png").toExternalForm()));
    } else if (type == ERROR) {
      fxLabelTitle.setText("Error");
      fxImageViewLogo.setImage(
          new Image(vbox.getClass().getResource(IMAGE_DIRECTORY + "error.png").toExternalForm()));
    }

    if (!message.equals("")) {
      fxLabelMessage.setText(message);
    }

    show(stage);
  }
  /**
   * This method is called when the splash screen has finished initializing the application. The
   * initialized resources are in a ServiceLocator singleton. Our task is to now create the
   * application MVC components, to hide the splash screen, and to display the application GUI.
   *
   * <p>Multitasking note: This method is called from an event-handler in the Splash_Controller,
   * which means that it is on the JavaFX Application Thread, which means that it is allowed to work
   * with GUI components. http://docs.oracle.com/javafx/2/threads/jfxpub-threads.htm
   */
  public void startApp() {
    // Stage appStage = new Stage();
    serverStage = new Stage();
    // Resources are now initialized
    ServiceLocator sl = ServiceLocator.getServiceLocator();
    Translator t = sl.getTranslator();
    System.out.println("BLABLA");
    try {
      final URL fxmlURL =
          getClass().getResource("/Server/Server.fxml"); // FXML-File from the ClientLogin-Window
      final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL);
      fxmlLoader.setController(new Server_Controller());
      final Parent root = fxmlLoader.load();
      Scene scene = new Scene(root, 650, 450);
      //			scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
      serverStage.setScene(scene);
      serverStage.setTitle(t.getString("program.name.windowName"));
      serverStage.show();
      String zwischenstatus = fxmlURL.toString();
      System.out.println("Application FXML Loader Pfad ist: " + zwischenstatus);
    } catch (Exception e) {
      e.printStackTrace();
    }

    // Close the splash screen, and set the reference to null, so that all
    // Splash_XXX objects can be garbage collected
    splashView.stop();
    splashView = null;

    //        view.start();
  }
Esempio n. 6
0
 public Controller(Main main, ResourceBundle bundle) throws IOException {
   this.main = main;
   URL location = new URL("file:ui/jfx/main.fxml");
   FXMLLoader fxmlLoader = new FXMLLoader(location, bundle);
   fxmlLoader.setController(this);
   fxmlLoader.load();
 }
  public MainStageController(Controller controller) {
    this.controller = controller;
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainStage.fxml"));
    fxmlLoader.setController(this);
    try {
      root = fxmlLoader.load();
    } catch (IOException e) {
      e.printStackTrace();
    }

    currentUserMenuButton.setText(controller.getCurrentUser().getName());
    collectAccountTable();
    accountsTable
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            new ChangeListener<Account>() {
              @Override
              public void changed(
                  ObservableValue<? extends Account> observable,
                  Account oldValue,
                  Account newValue) {
                controller.setCurrentAccount(accountsTable.getSelectionModel().getSelectedItem());
                showRecords(controller.getCurrentAccount());
                showBalanceLabel();
              }
            });

    showRecords(controller.getCurrentAccount());
    showBalanceLabel();
  }
Esempio n. 8
0
 public Controller(Main main, ResourceBundle bundle) throws IOException {
   this.main = main;
   URL location = new URL("file:ui/jfx/main.fxml");
   System.err.println(location.toExternalForm());
   FXMLLoader fxmlLoader = new FXMLLoader(location, bundle);
   fxmlLoader.setController(this);
   fxmlLoader.load();
 }
 public TabsController() {
   FXMLLoader loader = new FXMLLoader(getClass().getResource(COMMAND_BAR_LAYOUT_FXML));
   loader.setController(this);
   loader.setRoot(this);
   try {
     loader.load();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Esempio n. 10
0
  public static Parent loadFXML(Object ctrl, String fxml, Node root) throws IOException {
    FXMLLoader loader = new FXMLLoader(CooFileUtil.getResourceURL(fxml));

    if (root != null) {
      loader.setRoot(root);
    }

    loader.setController(ctrl);
    return loader.load();
  }
 private void loadFXML() {
   FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("EntryTask.fxml"));
   fxmlLoader.setRoot(this);
   fxmlLoader.setController(this);
   try {
     fxmlLoader.load();
   } catch (IOException e) {
     // TODO 自動生成された catch ブロック
     e.printStackTrace();
   }
 }
Esempio n. 12
0
  private void init() {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("View.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    try {
      fxmlLoader.load();
    } catch (IOException exception) {
      throw new RuntimeException(exception);
    }
  }
Esempio n. 13
0
 public InitialDashboardController() {
   FXMLLoader fxmlLoader =
       new FXMLLoader(getClass().getResource("/uchat/view/initialDashboardView.fxml"));
   fxmlLoader.setController(this);
   try {
     parent = fxmlLoader.load();
     scene = new Scene(parent, Main.PREF_WIDTH, Main.PREF_HEIGHT);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Esempio n. 14
0
 private void createGui() {
   try {
     final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("TimePicker.fxml"));
     fxmlLoader.setRoot(this);
     fxmlLoader.setController(this);
     fxmlLoader.load();
     getStylesheets().add(getClass().getResource("TimePicker.css").toExternalForm());
   } catch (final IOException e) {
     e.printStackTrace();
   }
 }
  public SourceListCellController() {

    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("../views/source-tile.fxml"));
    fxmlLoader.setController(this);
    try {
      fxmlLoader.load();
    } catch (Exception e) {
      // e.printStackTrace();
      System.out.print("\n\nIn source fxml load catch\n\n");
    }
  }
 /**
  * 戦闘ログ詳細のフェーズの艦船のコンストラクタ
  *
  * @param chara キャラクター
  */
 public BattleDetailPhaseShip(Chara chara) {
   this.chara = chara;
   try {
     FXMLLoader loader = InternalFXMLLoader.load("logbook/gui/battle_detail_phase_ship.fxml");
     loader.setRoot(this);
     loader.setController(this);
     loader.load();
   } catch (IOException e) {
     LoggerHolder.LOG.error("FXMLのロードに失敗しました", e);
   }
 }
Esempio n. 17
0
  @Override
  public Pane initialize(Presenter presenter, ModuleManager moduleManager) throws IOException {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(getClass().getResource("/employees/fxml/EmployeeTab.fxml"));
    loader.setController(new EmployeeTabController(presenter, moduleManager));

    // add hibernate shutdown listener
    presenter.addOnStopListener(HibernateUtils::shutdown);

    return loader.load();
  }
Esempio n. 18
0
  public HUD_3_2_1_Controller() {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FXML_HUD_simple.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    try {
      fxmlLoader.load();
    } catch (IOException exception) {
      throw new RuntimeException(exception);
    }
  }
Esempio n. 19
0
  /**
   * Creates a new MainView with the given fxmlFileName. The fxml file has to be in the same
   * namespace as the MainView.
   *
   * @param fxmlFileName the name of the fxml file to be loaded.
   */
  public MenuBarView(final String fxmlFileName) {
    final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(fxmlFileName));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    try {
      fxmlLoader.load();
    } catch (IOException exception) {
      throw new RuntimeException(exception);
    }
  }
  public FavoritesMenuPane() {
    FXMLLoader loader =
        new FXMLLoader(getClass().getResource("../../view/menupanes/FavoritesMenuPane.fxml"));

    loader.setRoot(this);
    loader.setController(this);
    try {
      loader.load();
    } catch (IOException excpt) {
      throw new RuntimeException(excpt);
    }
  }
Esempio n. 21
0
  public IntegerTextField() {

    FXMLLoader loader = new FXMLLoader(getClass().getResource("IntegerTextField.fxml"));
    loader.setRoot(this);
    loader.setController(this);

    try {
      loader.load();
    } catch (final IOException exception) {
      throw new RuntimeException(exception);
    }
  }
Esempio n. 22
0
 public ConsolePanel(int id) {
   this.id = id;
   FXMLLoader loader =
       new FXMLLoader(getClass().getResource("controlStation/console/console_panel.fxml"));
   loader.setLocation(ClassLoader.getSystemResource("controlStation/console/console_panel.fxml"));
   controller = new ConsolePanelController();
   loader.setController(controller);
   try {
     root = loader.load();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Esempio n. 23
0
 public Parent getRoot() {
   if (this.root == null) {
     try {
       final URL url = this.getClass().getResource(fxml);
       final FXMLLoader loader = new FXMLLoader(url);
       loader.setController(this);
       loader.load();
       this.root = loader.getRoot();
     } catch (final IOException exception) {
       throw new RuntimeException(exception);
     }
   }
   return root;
 }
Esempio n. 24
0
  /** constructs a new editing pane and loads the FXML into the main stage */
  public EditingPane() {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/layouts/EditingLayout.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);
    try {
      fxmlLoader.load();
    } catch (IOException exception) {
      throw new RuntimeException(exception);
    }

    type.setItems(typeOptions);

    backgroundSelected();
  }
  public InteractionsListController() {
    logger.entry();
    FXMLLoader fxmlLoader =
        new FXMLLoader(getClass().getResource("/fxml/customcontrol/InteractionsList.fxml"));
    fxmlLoader.setController(this);
    fxmlLoader.setRoot(this);
    try {
      fxmlLoader.load();

    } catch (IOException ex) {
      logger.log(Level.FATAL, ex.getMessage(), ex);
    }
    logger.exit();
  }
Esempio n. 26
0
 public PropertyEditor(String fxmlFile) {
   try {
     FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFile));
     loader.setController(this);
     Parent root = (Parent) loader.load();
     getChildren().add(root);
     AnchorPane.setTopAnchor(root, 0.0);
     AnchorPane.setLeftAnchor(root, 0.0);
     AnchorPane.setRightAnchor(root, 0.0);
     AnchorPane.setBottomAnchor(root, 0.0);
   } catch (IOException e) {
     e.printStackTrace();
     System.exit(1);
   }
 }
Esempio n. 27
0
  public DeckListView() {
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/DeckListView.fxml"));
    fxmlLoader.setRoot(this);
    fxmlLoader.setController(this);

    try {
      fxmlLoader.load();
    } catch (IOException exception) {
      throw new RuntimeException(exception);
    }

    newDeckButton.setOnAction(
        actionEvent -> NotificationProxy.sendNotification(GameNotification.CREATE_NEW_DECK));
    setCache(true);
  }
Esempio n. 28
0
 /**
  * Creates a JavaFX scene
  *
  * @return the JavaFX scene
  */
 private Scene createScene() {
   Parent root = null;
   try {
     FXMLLoader loader = new FXMLLoader(getClass().getResource("FXMLTestDocument.fxml"));
     FXMLTestResultsDocumentController controller = new FXMLTestResultsDocumentController();
     loader.setController(controller);
     loader.setClassLoader(getClass().getClassLoader());
     root = (Parent) loader.load();
     System.out.println(loader.getController().toString());
     System.out.println(loader.getLocation());
     return new Scene(root);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return new Scene(root);
 }
Esempio n. 29
0
  /** constructs a new error stage without displaying any error */
  public ErrorStage() {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/layouts/ErrorLayout.fxml"));
    loader.setController(this);

    Parent p;
    try {
      p = loader.load();
    } catch (IOException exception) {
      throw new RuntimeException(exception);
    }

    stage.setTitle("Error");
    stage.setScene(new Scene(p));
    stage.getIcons().add(new Image(getClass().getResourceAsStream("/resources/Amp.png")));
    stage.setResizable(false);
  }
Esempio n. 30
0
  public PreviewsView(EventBus eventBus) {
    checkNotNull(eventBus);

    this.eventBus = eventBus;
    this.previewedSockets = new ArrayList<>();

    try {
      FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Previews.fxml"));
      fxmlLoader.setRoot(this);
      fxmlLoader.setController(this);
      fxmlLoader.load();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    this.eventBus.register(this);
  }