@Override
 public void start(Stage primaryStage) throws Exception {
   initApplicationDirs();
   File dataDir = new File(applicationDataDir());
   if (dataDir.exists()) {
     LoginWindow loginWindow = new LoginWindow();
     loginWindow.displayLoginAndWait();
     boolean isAuthenticated = SEAGridContext.getInstance().getAuthenticated();
     if (isAuthenticated) {
       HomeWindow homeWindow = new HomeWindow();
       Screen screen = Screen.getPrimary();
       Rectangle2D bounds = screen.getVisualBounds();
       primaryStage.setX(bounds.getMinX());
       primaryStage.setY(bounds.getMinY());
       primaryStage.setWidth(bounds.getWidth());
       primaryStage.setHeight(bounds.getHeight());
       homeWindow.start(primaryStage);
       primaryStage.setOnCloseRequest(
           t -> {
             Platform.exit();
             System.exit(0);
           });
     }
   } else {
     SEAGridDialogHelper.showExceptionDialogAndWait(
         new Exception("Application Data Dir Does Not Exists"),
         "Application Data Dir Does Not Exists",
         null,
         "Application Data Dir Does Not Exists");
     System.exit(0);
   }
 }
Esempio n. 2
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");
  }
Esempio n. 3
0
  private void displayConnectionPopup(Stage primaryStage) {
    Stage connectStage;

    connectStage = new Stage();
    connectStage.initModality(Modality.WINDOW_MODAL);
    connectStage.setScene(new Scene(new FxmlLoadable("/erlyberly/connection.fxml").load()));
    connectStage.setAlwaysOnTop(true);

    // javafx vertical resizing is laughably ugly, lets just disallow it
    connectStage.setResizable(false);
    connectStage.setWidth(400);

    // if the user closes the window without connecting then close the app
    connectStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent e) {
            if (!nodeAPI.connectedProperty().get()) {
              Platform.exit();
            }

            Platform.runLater(
                () -> {
                  primaryStage.setResizable(true);
                });
          }
        });

    connectStage.show();
  }
Esempio n. 4
0
    @Override
    public void start(final Stage stage) throws Exception {
        this.stage = stage;
        stage.initStyle(StageStyle.UNDECORATED);
        stage.setTitle("PainelFX");
        stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
            @Override
            public void handle(WindowEvent t) {
                self.hide();
            }
        });
        
        // loop infinito
        TimelineBuilder.create().keyFrames(new KeyFrame(Duration.millis(100), new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                long time = Calendar.getInstance().getTimeInMillis();
                // processando fila de senha
                processQueue();
                // verificando screensaver
                if (currentLayout != null && !currentLayout.equals(screenSaverLayout)) {
                    Integer screenSaverTimeout = main.getConfig().get(PainelConfig.KEY_SCREENSAVER_TIMEOUT, Integer.class).getValue();
                    if (screenSaverTimeout > 0) {
                        if (time - lastUpdate > screenSaverTimeout * 1000) {
                            self.changeLayout(screenSaverLayout);
                        }
                    }
                }
            }
        })).cycleCount(-1).build().play();

        detectScreen();
        senhaLayout = new SimpleSenhaLayout(this);
        screenSaverLayout = new VideoLayout(this);
    }
  public SQLHistorySearchCtrl(
      SQLTextAreaServices sqlTextAreaServices,
      Session session,
      ObservableList<SQLHistoryEntry> items) {
    _sqlTextAreaServices = sqlTextAreaServices;

    FxmlHelper<SQLHistorySearchView> fxmlHelper = new FxmlHelper<>(SQLHistorySearchView.class);
    _view = fxmlHelper.getView();

    _dialog = new Stage();
    _dialog.setTitle(
        new I18n(getClass())
            .t("SQLHistorySearchCtrl.title", session.getMainTabContext().getSessionTabTitle()));
    _dialog.initModality(Modality.WINDOW_MODAL);
    _dialog.initOwner(AppState.get().getPrimaryStage());
    Region region = fxmlHelper.getRegion();
    _dialog.setScene(new Scene(region));

    GuiUtils.makeEscapeClosable(region);

    new StageDimensionSaver(
        "sqlhistorysearch",
        _dialog,
        new Pref(getClass()),
        region.getPrefWidth(),
        region.getPrefHeight(),
        _dialog.getOwner());

    _view.cboFilterType.setItems(
        FXCollections.observableList(Arrays.asList(SqlHistoryFilterType.values())));
    _view.cboFilterType.getSelectionModel().selectFirst();

    _view.btnApply.setOnAction(e -> onApply());
    _view.chkFiltered.setOnAction(e -> onChkFiltered());

    _view.split.getItems().add(_tblHistory);
    _view.split.getItems().add(_txtSqlPreview);

    _originalTableLoader = new RowObjectTableLoader<>();
    _originalTableLoader.initColsByAnnotations(SQLHistoryEntry.class);
    _originalTableLoader.addRowObjects(items);
    _currentLoader = _originalTableLoader.cloneLoader();
    _currentLoader.load(_tblHistory);

    _tblHistory
        .getSelectionModel()
        .selectedItemProperty()
        .addListener((observable, oldValue, newValue) -> onTableSelectionChanged());

    _tblHistory.setOnMouseClicked(e -> onTblHistoryClicked(e));

    _txtSqlPreview.setEditable(false);

    _dialog.setOnCloseRequest(e -> close());

    _view.txtFilter.requestFocus();

    _splitPositionSaver.apply(_view.split);
    _dialog.showAndWait();
  }
Esempio n. 6
0
  /** Sestaví nové okno. */
  public Stage build() {
    if (onCloseEvent != null) stage.setOnCloseRequest(onCloseEvent);
    if (onHidingEvent != null) stage.setOnHiding(onHidingEvent);

    scene.setRoot(root);
    ObservableList<String> styleSheets = scene.getStylesheets();
    styleSheets.addAll(
        styles
            .stream()
            .map(style -> "file:///" + (fm.getFolderCSS() + style).replace("\\", "/"))
            .collect(Collectors.toList()));

    stage.setScene(scene);
    stage.setOnCloseRequest(event -> stage.close());
    return stage;
  }
  @Override
  public void start(Stage primaryStage) {
    String url = handler.getConnectionUrl();

    WebView browser = new WebView();
    WebEngine webEngine = browser.getEngine();
    webEngine.load(url);

    StackPane root = new StackPane();
    root.getChildren().add(browser);

    Scene scene = new Scene(root, 650, 500);

    primaryStage.setTitle("Acces Token Getter");
    primaryStage.setScene(scene);
    primaryStage.show();

    primaryStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          public void handle(WindowEvent we) {
            try {
              String urlWithAT = webEngine.getLocation();
              handler.setInputUrl(urlWithAT);
              handler.parseUrl();
              handler.writeAccesTokenToFile(OUTPUT_FILE_NAME);
              System.out.print("See file: " + OUTPUT_FILE_NAME);
            } catch (Exception e) {
              System.out.print(e.getMessage());
            }
          }
        });
  }
Esempio n. 8
0
  @Override
  public void start(Stage primaryStage) {
    this.primaryStage = primaryStage;
    ApplicationContextHolder.getContext();
    startLogAppender();
    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionLogger());
    primaryStage.setScene(initScene());
    primaryStage
        .getIcons()
        .addAll(ApplicationContextHolder.getContext().getBeansOfType(Image.class).values());
    primaryStage.setTitle(ApplicationContextHolder.getContext().getBean(Pdfsam.class).name());
    primaryStage.setOnCloseRequest(e -> Platform.exit());
    initWindowsStatusController(primaryStage);
    initOverwriteDialogController(primaryStage);
    initActiveModule();
    primaryStage.show();

    requestCheckForUpdateIfNecessary();
    requestLatestNewsPanelDisplay();
    eventStudio().addAnnotatedListeners(this);
    closeSplash();
    STOPWATCH.stop();
    LOG.info(
        DefaultI18nContext.getInstance()
            .i18n(
                "Started in {0}",
                DurationFormatUtils.formatDurationWords(STOPWATCH.getTime(), true, true)));
  }
Esempio n. 9
0
  @Override
  public void start(Stage ps) throws Exception {
    window = ps;
    control = new WindowControl();

    music = new MediaPlayer(new Media(Util.getResource("music.mp3").toString()));
    breakSound = new MediaPlayer(new Media(Util.getResource("asteroid_break.mp3").toString()));
    explosionSound = new MediaPlayer(new Media(Util.getResource("explosion.mp3").toString()));

    window.setTitle("Asteroids: Space adventure - By macjuul");

    Image icon_128 = Util.getImage("icon_128.png");
    Image icon_32 = Util.getImage("icon_32.png");
    Image icon_16 = Util.getImage("icon_16.png");

    window.getIcons().addAll(icon_128, icon_32, icon_16);

    window.setMinWidth(WIDTH);
    window.setMinHeight(HEIGHT);
    window.setWidth(WIDTH);
    window.setHeight(HEIGHT);

    Parent layout = (Parent) control.loadLayout();

    Scene s = new Scene(layout);

    // Set our stylesheet
    s.getStylesheets().add(Util.getResource("window/style.css").toExternalForm());

    s.setCursor(Cursor.CROSSHAIR);

    window.setScene(s);

    window
        .widthProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number oldN, Number newN) -> {
              WIDTH = newN.intValue();

              updateDimensions(true);
            });

    window
        .heightProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number oldN, Number newN) -> {
              HEIGHT = (int) newN.intValue();

              updateDimensions(true);
            });

    // Open the window
    window.show();

    window.setOnCloseRequest(
        e -> {
          Platform.exit();
          System.exit(0);
        });
  }
Esempio n. 10
0
  @Override
  public void start(Stage primaryStage) throws Exception {

    ScreenContainer mainScreen = new ScreenContainer();

    // Adding the screens
    mainScreen.loadScreen("login", "/screens/client/login.fxml");
    mainScreen.loadScreen("main", "/screens/client/main.fxml");

    // Showing the main screen
    mainScreen.showScreen("login");
    primaryStage.setOnCloseRequest(
        event -> {
          mainScreen.closeScreen();
        });
    // Displaying the stage
    Group root = new Group();
    root.getChildren().addAll(mainScreen);
    Scene scene =
        new Scene(
            root); // , root.getLayoutBounds().getWidth(), root.getLayoutBounds().getHeight());
    primaryStage.setScene(scene);
    primaryStage.minHeightProperty().bind(mainScreen.heightProperty());
    primaryStage.minWidthProperty().bind(mainScreen.widthProperty());
    primaryStage.setTitle("Chat Client");
    primaryStage.show();
  }
Esempio n. 11
0
  @Override
  public void start(Stage stage) throws Exception {
    primaryStage = stage;

    primaryStage.setTitle("Générateur de trames de surveillances");

    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(Main.class.getResource("../../../zoo/generator/view/RootLayout.fxml"));

    try {
      rootLayout = loader.load();
      Scene scene = new Scene(rootLayout);
      primaryStage.setScene(scene);

      // Main panel
      FXMLLoader loader2 = new FXMLLoader();
      loader2.setLocation(Main.class.getResource("../../../zoo/generator/view/MainPanel.fxml"));
      BorderPane o = loader2.load();

      scene.setRoot(o);

      MainPanelController controller = loader2.getController();
      controller.setRandomGenerationService(RandomGenerationService.getInstance());

      primaryStage.show();

      primaryStage.setOnCloseRequest(
          new EventHandler<WindowEvent>() {

            @Override
            public void handle(WindowEvent event) {
              System.out.println("Arrêt des threads");
              Thread[] threads = new Thread[100];

              int n = Thread.enumerate(threads);

              for (int i = 0; i < n; i++) {
                System.out.println(threads[i]);
              }

              // 1. Stop random generation
              RandomGenerationService.getInstance().stop();

              // 2. Stop server thread
              Server.getInstance().stop();

              // 3. Stop client threads
              ClientHandler.stopAll();

              System.out.println("Après l'arrêt des threads");
            }
          });

      Server.getInstance().start();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public void init(URI serverEndpointAddress) {
    logger.debug("Reached controller initialize");

    initWebsocketClient(serverEndpointAddress);
    Stage stage = getStage();
    EventHandler<WindowEvent> eh = new MyCloseHandler(stage);
    stage.setOnCloseRequest(eh);
  }
Esempio n. 13
0
  @Override
  public void showGui(Stage stage, int width, int height) {
    this.width = width;
    this.height = height;
    this.stage = stage;
    this.jobsManager = JobsManager.create();
    final FXMLLoader loader = new FXMLLoader();
    try {
      root = loader.load(GuiAgentImpl.class.getResourceAsStream(GUI_AGENT_FXML));
      ctrl = loader.getController();
    } catch (IOException e) {
      LOGGER.severe("Cannot load " + GUI_AGENT_FXML + " !");
      System.exit(0);
    }

    scene = new Scene(root, this.width, this.height, Color.ALICEBLUE);
    this.loadCss(scene);

    dockManager.init(root, scene, height, width);
    dockManager.makeDock();

    createMOBWidget(scene);

    // Place scene components
    ctrl.leftBorderPane.setCenter(layerTreeServices.getDisplayService().getDisplayable());
    ctrl.centerStackPane.getChildren().add(geoViewServices.getDisplayService().getDisplayable());
    ctrl.statusBorderPane.setRight(jobsManager.getDisplay().getDisplayable());

    // Initialize menu
    // this.menuServices.setMenuComponent(ctrl.menuBar);
    // this.initializeMenuItems(this.menuServices);
    stage.setTitle(TITLE);
    stage.setOnCloseRequest(
        e -> {
          LOGGER.info("Stop Application");
          ComponentManager.componentManager.stopApplication();
          System.exit(0);
        });
    stage.setScene(scene);
    // stage.setFullScreen(true);
    stage.show();

    // Deuxieme stage pour le sonar, pour qu'il reste au dessus, bug sur l'api ?
    stage1 = new Stage();
    stage1.setOpacity(.0);
    stage1.setHeight(400);
    stage1.setWidth(400);
    stage1.setX(600);
    stage1.setY(200);
    stage1.initStyle(StageStyle.UNDECORATED);

    // test Slider pour layers
    //   SliderController sliderController = new SliderController();
    //   root.getChildren().add(sliderController);
  }
Esempio n. 14
0
 @Override
 public void start(Stage stage) throws Exception {
   stage.setTitle("Tetris");
   Group root = new Group();
   Scene scene = new Scene(root, 800, 400);
   stage.setScene(scene);
   stage.show();
   SceneManager scmanager = new SceneManager(stage, scene, root);
   stage.setOnCloseRequest(scmanager.getOnCloseWindow());
   scmanager.launch();
 }
 public void showWindow() {
   // resize primary stage to full screen
   Screen primaryScreen = Screen.getPrimary();
   Rectangle2D bounds = primaryScreen.getVisualBounds();
   Stage mainWindowStage = (Stage) mainWindowRoot.getScene().getWindow();
   mainWindowStage.setX(bounds.getMinX());
   mainWindowStage.setY(bounds.getMinY() + 98);
   mainWindowStage.setWidth(bounds.getWidth());
   mainWindowStage.setHeight(1080); // bounds.getHeight()
   mainWindowStage.setOnCloseRequest(event -> quit());
 }
Esempio n. 16
0
 @Override
 public void start(Stage stage) throws Exception {
   String fxmlFile = "/chat.fxml";
   FXMLLoader loader = new FXMLLoader();
   Parent root = loader.load(getClass().getResourceAsStream(fxmlFile));
   stage.setTitle("Chat");
   stage.setScene(new Scene(root));
   stage.getScene().getStylesheets().add("/css/JMetroLightTheme.css");
   stage.show();
   stage.setOnCloseRequest(event -> Controller.getInst().close());
 }
Esempio n. 17
0
  public static void showTaskProgressDialog(
      Window ownerWindow, Task task, boolean showTaskMessage) {
    final Stage dialog = new Stage();
    task.setOnSucceeded(event -> dialog.close());
    task.setOnCancelled(event -> dialog.close());
    dialog.initStyle(StageStyle.UTILITY);
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initOwner(ownerWindow);
    dialog.titleProperty().bind(task.titleProperty());
    //        dialog.setTitle(ResourceManager.getMessage("title.dialog.processing"));
    dialog.setOnCloseRequest(
        event ->
            Logger.getLogger(Dialogs.class)
                .info(ResourceManager.getMessage("notification.task.terminatedByUser")));

    ProgressBar progressBar = new ProgressBar(0);
    progressBar.progressProperty().bind(task.progressProperty());
    progressBar.setMaxWidth(Double.MAX_VALUE);
    progressBar.getStyleClass().add("dark");

    Label label = new Label(ResourceManager.getMessage("label.pleaseWaitWhile"));
    Label taskMessage = new Label();
    taskMessage.textProperty().bind(task.messageProperty());

    Button cancelButton = new Button(ResourceManager.getMessage("label.button.cancel"));
    cancelButton.setOnAction(
        event -> {
          task.cancel();
          Logger.getLogger(Dialogs.class)
              .info(ResourceManager.getMessage("notification.task.terminatedByUser"));
        });

    ButtonBar buttonBar = new ButtonBar();
    buttonBar.getButtons().add(cancelButton);

    VBox dialogVBox = new VBox();
    dialogVBox.setFillWidth(true);
    dialogVBox.setSpacing(5);
    dialogVBox.setPadding(new Insets(5));
    dialogVBox.setPrefSize(300, VBox.USE_COMPUTED_SIZE);
    dialogVBox.getChildren().add(label);
    if (showTaskMessage) {
      dialogVBox.getChildren().add(taskMessage);
    }
    dialogVBox.getChildren().add(progressBar);
    dialogVBox.getChildren().add(buttonBar);

    Scene dialogScene = new Scene(dialogVBox);
    dialogScene.getStylesheets().add(ResourceManager.getUIThemeStyle());
    dialog.setScene(dialogScene);
    dialog.setResizable(false);
    dialog.show();
  }
Esempio n. 18
0
  @Override
  public void start(Stage primaryStage) {
    System.out.println("GUI.start()");
    EnumPolicy.load();
    EnumRegion.loadIcons();
    // TODO: THIS WILL BE REMOVED WHEN PHASE HANDLING IS FULLY IMPLEMENTED
    MapController.setCurrentController(GamePhaseMapController.class);
    this.primaryStage = primaryStage;
    primaryStage.setTitle("Starvation Evasion");

    // fills a list of all the product types

    // primaryStage.setMaxHeight(maxHeight);
    // primaryStage.setMinHeight(maxHeight);
    primaryStage.setResizable(true);

    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();

    primaryStage.setX(bounds.getMinX());
    primaryStage.setY(bounds.getMinY());
    primaryStage.setWidth(bounds.getWidth());
    primaryStage.setHeight(bounds.getHeight());

    boxHeight = primaryStage.getWidth() / DraftLayout.ROWS;
    boxWidth = primaryStage.getWidth() / DraftLayout.COLS;

    // instantiate helper classes
    imageGetter = new ImageGetter();
    popupManager = new PopupManager(this);
    graphManager = new GraphManager(this);

    // instantiate the DraftLayout
    draftLayout = new DraftLayout(this);
    votingLayout = new VotingLayout(this);
    // make a scene for displaying the game
    gameScene = new Scene(draftLayout);
    currentRoot = draftLayout;
    primaryStage.setScene(gameScene);

    primaryStage.show();

    primaryStage.setOnCloseRequest(
        arg0 -> {
          if (client != null) client.shutdown();
          Platform.exit();
        });

    initGame();
  }
Esempio n. 19
0
 @Override
 public void start(Stage primaryStage) {
   try {
     System.loadLibrary("CLIPSJNI");
     Parent root = FXMLLoader.load(getClass().getResource("norber.fxml"));
     Scene scene = new Scene(root, 1200, 600);
     scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
     primaryStage.setTitle("Primeros Auxilios");
     primaryStage.setOnCloseRequest(e -> onClose());
     primaryStage.setScene(scene);
     primaryStage.show();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  private void seadistaLava() {
    maailm = new StackPane();
    laud = new GridPane();

    maailm.getChildren().add(laud);

    Scene manguStseen =
        new Scene(maailm, laevaServaPikkus * lauaPikkus, laevaServaPikkus * lauaPikkus);
    lava.setScene(manguStseen);
    lava.show(); // näita akent
    lava.setOnCloseRequest(
        event -> {
          System.exit(0);
        }); // akna sulgedes läheb programm kinni
  }
Esempio n. 21
0
 /**
  * This is the main stage that everything will be added on. Including: Main menu,Options Menu, Map
  * Editor and the game itself.
  */
 @Override
 public void start(Stage primaryStage) {
   new MenuHandler(primaryStage);
   MenuHandler.switchScene(MenuHandler.MAIN_MENU);
   primaryStage.initStyle(StageStyle.UNDECORATED);
   primaryStage.setOnCloseRequest(
       e -> {
         CoreEngine engine = CoreEngine.Instance();
         if (engine != null) {
           engine.setRunning(false);
         }
         LOG.log(Level.INFO, "Exiting...");
         System.exit(0);
       });
   primaryStage.show();
 }
Esempio n. 22
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    (new HelpFileThread())
        .start(); // load to help file from the resource folder to the local temp folder.

    Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
    primaryStage.setTitle("Virtual Filesystem");
    primaryStage.setScene(new Scene(root, 800, 600));
    primaryStage.show();
    primaryStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent event) {
            FileSystemManger.getInstance().close();
          }
        });
  }
Esempio n. 23
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    this.primaryStage = primaryStage;
    final Database database = new Database();

    // FXML loader for the main scene
    Parent root = FXMLLoader.load(getClass().getResource("FXML/sample.fxml"));
    // Main scene with FXML file loaded
    mainScene = new Scene(root);

    primaryStage.setTitle("ET Database Management");
    primaryStage.setScene(mainScene);

    // Window minimum dimensions
    primaryStage.setMinWidth(800);
    primaryStage.setMinHeight(600);

    // On close action for the primary stage, handles the shut down of the database server
    primaryStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent event) {
            try {
              // Shuts the server down
              database.serverAction(false);
              Platform.exit();
            } catch (Exception exception) {
              database.createAlertDialog(exception, "The server couldn't shut down");
            }
          }
        });

    // Initiate Database Server
    try {
      // Starts the database server
      database.serverAction(true);

      // Show main window
      primaryStage.show();
    } catch (Exception exception) {
      Alert alert = database.createAlertDialog(exception, "The database server couldn't start");
      alert.showAndWait();
      primaryStage.close();
    }
  }
Esempio n. 24
0
  private void showUI(Stage primaryStage, String name, String version) {
    SmartCSVController smartCVSController = appContext.getBean(SmartCSVController.class);
    Scene scene = new Scene((Parent) smartCVSController.getView());

    primaryStage.setScene(scene);
    primaryStage.setTitle(String.format("%s %s", name, version));
    primaryStage.show();
    primaryStage.setMaximized(true);

    primaryStage.setOnCloseRequest(
        event -> {
          if (!smartCVSController.canExit()) {
            event.consume();
          } else {
            exit();
          }
        });
  }
Esempio n. 25
0
 @Override
 public void start(Stage primaryStage) throws Exception {
   FXMLLoader loader = new FXMLLoader(this.getClass().getResource("sample.fxml"));
   Parent root = (Parent) loader.load();
   //        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
   primaryStage.setTitle("Hello World");
   primaryStage.setScene(new Scene(root, 700, 525));
   primaryStage.show();
   Controller controller = loader.getController();
   controller.startCamera();
   primaryStage.setOnCloseRequest(
       new EventHandler<WindowEvent>() {
         @Override
         public void handle(WindowEvent event) {
           System.out.println("Bye-bye, Huston");
           controller.stopCamera();
         }
       });
 }
Esempio n. 26
0
  @Override
  public void start(Stage stage) throws Exception {
    FXMLLoader loader = new FXMLLoader();
    MainController controller = context.getBean(MainController.class);
    loader.setControllerFactory(
        new Callback<Class<?>, Object>() {

          @Override
          public Object call(Class<?> param) {
            return controller;
          }
        });
    Parent root = loader.load(getClass().getResourceAsStream("/fxml/Scene.fxml"));
    Scene scene = new Scene(root);
    scene.getStylesheets().add("/styles/Styles.css");
    String prop = "/application.properties";
    String name = PropertiesUtil.getProperty(prop, "project.name");
    String version = PropertiesUtil.getProperty(prop, "project.version");
    stage.setTitle(name + "    " + version);
    stage.getIcons().add(new Image(getClass().getResourceAsStream("/image/mongodb-logo.png")));
    stage.setScene(scene);
    stage.show();
    stage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {

          @Override
          public void handle(WindowEvent event) {
            Dialog<ButtonType> dialog = new Dialog<>();
            dialog.setContentText("\r\n\r\n是否退出?\r\n\r\n");
            dialog.setTitle("退出提示");
            dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
            dialog
                .showAndWait()
                .ifPresent(
                    res -> {
                      if (res != ButtonType.OK) {
                        event.consume();
                      }
                    });
          }
        });
  }
Esempio n. 27
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    BorderPane layout = new BorderPane();

    // imageview
    currImage = new ImageView();
    layout.setMargin(currImage, new Insets(25, 180, 0, 180));
    currImage.setSmooth(true);
    layout.setTop(currImage);

    // add bottom layout
    BottomLayout bottomLayoutObject = new BottomLayout(primaryStage);
    HBox bottomLayout = bottomLayoutObject.getLayout();
    bottomLayout.setAlignment(Pos.BOTTOM_RIGHT);
    layout.setBottom(bottomLayout);

    currImage.setOnMouseClicked(
        e -> {
          clicked = !clicked;

          if (clicked) {
            BottomLayout.statusBar.setText("Paused");

            ImageSelector.timer.cancel();
            stoppedCount = ImageSelector.count;
          } else {
            BottomLayout.statusBar.setText("Running the images display");
            ImageSelector.startSelectImages(ImageSelector.currPath);
          }
        });

    // cancel the timer if the user exited the program
    primaryStage.setOnCloseRequest(
        e -> {
          if (ImageSelector.timer != null) ImageSelector.timer.cancel();
        });

    primaryStage.setTitle("Images Displayer");
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(layout, 900, 600));
    primaryStage.show();
  }
 @Override
 public void start(Stage primaryStage) {
   LifeGameController.setWindowactive(true);
   try {
     AnchorPane page =
         (AnchorPane) FXMLLoader.load(JavaFXApplication1.class.getResource("MainWindow.fxml"));
     Scene scene = new Scene(page);
     primaryStage.setScene(scene);
     primaryStage.setTitle("Conway's Game of Life 20 x 20");
     primaryStage.setOnCloseRequest(
         new EventHandler<WindowEvent>() {
           public void handle(WindowEvent t) {
             LifeGameController.setWindowactive(false);
           }
         });
     primaryStage.show();
   } catch (Exception ex) {
     Logger.getLogger(JavaFXApplication1.class.getName()).log(Level.SEVERE, null, ex);
   }
 }
Esempio n. 29
0
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("Traffic Light Server");

    try {
      FXMLLoader loader = new FXMLLoader(ServerMain.class.getResource("viewClient.fxml"));

      AnchorPane page = loader.load();

      Scene scene = new Scene(page);

      primaryStage.setScene(scene);

      primaryStage.show();
      primaryStage.setOnCloseRequest(e -> System.exit(1));
    } catch (IOException e) {
      System.err.println("Error loading view.fxml!");
      e.printStackTrace();
    }
  }
Esempio n. 30
0
  @Override
  public void start(Stage primaryStage) throws Exception {

    Scene scene = new Scene(this.root);

    primaryStage.setResizable(false);
    primaryStage.setOnCloseRequest(
        e -> {
          String empty[] = null;
          this.chatConsoleReader.proccessCommand("exit", empty);
          Platform.exit();
          System.exit(0);
        });
    primaryStage.setTitle(
        "Chat: "
            + ChatConsoleReader.getInstance().getController().getChatroom()
            + "@"
            + ChatConsoleReader.getInstance().getController().getIP());
    primaryStage.setScene(scene);
    primaryStage.show();
  }