@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); } }
@Override public void start(Stage stage) { Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); stage.setWidth(bounds.getWidth()); stage.setHeight(bounds.getHeight()); stage.setResizable(false); new CellSocietyGUI(stage); }
private void setupStageLocation(Stage stage) { ObservableList<Screen> screens = Screen.getScreens(); Screen screen = screens.size() <= screenNumber ? Screen.getPrimary() : screens.get(screenNumber); Rectangle2D bounds = screen.getBounds(); boolean primary = screen.equals( Screen.getPrimary()); // WORKAROUND: this doesn't work nice in combination with full // screen, so this hack is used to prevent going fullscreen when // screen is not primary if (primary) { stage.setX(bounds.getMinX()); stage.setY(bounds.getMinY()); stage.setWidth(bounds.getWidth()); stage.setHeight(bounds.getHeight()); stage.setFullScreen(true); } else { stage.setX(bounds.getMinX()); stage.setY(bounds.getMinY()); stage.setWidth(bounds.getWidth()); stage.setHeight(bounds.getHeight()); stage.toFront(); } }
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(); }
public void storeEntry() { Stage window = new Stage(); Button button; Label label = new Label("Please enter the item UPC"); Label label2 = new Label("Please enter the item's location"); window.initModality(Modality.APPLICATION_MODAL); window.setTitle("Save an item"); window.setWidth(300); window.setHeight(400); final TextField upcInput = new TextField(); final TextField locationInput = new TextField(); button = new Button("Save"); button.setOnAction( e -> { try { itemUPC = Double.parseDouble(upcInput.getText()); itemLOC = locationInput.getText(); } catch (Exception f) { displaySimple("Bad input", "Please enter valid inputs"); status = false; } window.close(); }); VBox layout = new VBox(20); layout.getChildren().addAll(label, upcInput, label2, locationInput, button); layout.setAlignment(Pos.CENTER); Scene scene = new Scene(layout); window.setScene(scene); window.showAndWait(); }
public void customerEntry() { Stage window = new Stage(); Button button; Label label = new Label("Please enter the item you are searching for"); window.initModality(Modality.APPLICATION_MODAL); window.setTitle("Find an item"); window.setWidth(400); window.setHeight(400); final TextField nameInput = new TextField(); button = new Button("Find"); button.setOnAction( e -> { try { userEntry = nameInput.getText(); } catch (Exception f) { displaySimple("Bad input", "Please enter valid inputs"); status = false; } window.close(); }); VBox layout = new VBox(20); layout.getChildren().addAll(label, nameInput, button); layout.setAlignment(Pos.CENTER); Scene scene = new Scene(layout); window.setScene(scene); window.showAndWait(); }
public void storeLogin() { Stage window = new Stage(); Button button; String password = "******"; Label label = new Label("Please enter the store password"); window.initModality(Modality.APPLICATION_MODAL); window.setTitle("Store Login"); window.setWidth(300); window.setHeight(200); final TextField passWordInput = new TextField(); button = new Button("Enter"); button.setOnAction( e -> { String entry = passWordInput.getText(); if (entry.equalsIgnoreCase(password)) { answer = true; window.close(); } else { answer = false; window.close(); } }); VBox layout = new VBox(20); layout.getChildren().addAll(label, passWordInput, button); layout.setAlignment(Pos.CENTER); Scene scene = new Scene(layout); window.setScene(scene); window.showAndWait(); }
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle(Msg.get(this, "title")); primaryStage.setOpacity(Msg.get(this, "stage.opacity", Double::parseDouble, 1.0)); Group root = new Group(); Button btnHello = new Button(Msg.get(this, "btnHello.text")); root.getChildren().add(btnHello); Scene scene = new Scene( root, Msg.get(this, "scene.width", Integer::parseInt, 300), Msg.get(this, "scene.height", Integer::parseInt, 300)); primaryStage.setScene(scene); // primaryStage.sizeToScene(); primaryStage.setWidth(Msg.get(this, "stage.width", Integer::parseInt, 300)); primaryStage.setHeight(Msg.get(this, "stage.height", Integer::parseInt, 300)); primaryStage.show(); // Center the stage to window only after the stage has been shown Rectangle2D bounds = Screen.getPrimary().getVisualBounds(); double x = bounds.getMinX() + (bounds.getWidth() - primaryStage.getWidth()) / 2; double y = bounds.getMinY() + (bounds.getHeight() - primaryStage.getHeight()) / 2; // primaryStage.setX(x); primaryStage.setY(y); }
@Test public void testConceptNewJump() { // given Set<Node> newButtons = conceptMapView.lookupAll(".newBtnTop"); Node firstNewButton = newButtons.iterator().next(); moveTo(firstNewButton).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY); Node concept = conceptMapView.lookup(".concept"); double expectedX = concept.getLayoutX() + concept.getTranslateX(); double expectedY = concept.getLayoutY() + concept.getTranslateY(); // when super.interact( () -> { stage.setFullScreen(false); stage.setWidth(stage.getWidth() - 40); stage.setHeight(stage.getHeight() - 40); }); // then double actualX = concept.getLayoutX() + concept.getTranslateX(); double actualY = concept.getLayoutY() + concept.getTranslateY(); assertEquals(expectedX, actualX, 50); assertEquals(expectedY, actualY, 50); }
@Override public void start(Stage primaryStage) throws IOException { Parent root = FXMLLoader.load(getClass().getResource("FXML.fxml")); scene = new Scene(root); primaryStage.setScene(scene); Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds(); primaryStage.setWidth(720); primaryStage.setHeight(576); primaryStage.show(); /** Keycode handler reader for barcode reader */ scene.setOnKeyPressed( new EventHandler<javafx.scene.input.KeyEvent>() { @Override public void handle(javafx.scene.input.KeyEvent event) { if (event.getCode().equals(KeyCode.ENTER)) { System.out.println("ENTER + " + terminal.getBarcodeReader()); String code = "" + (Long.valueOf(terminal.getBarcodeReader())); if (terminal.isBarcodeNew()) { udp.sendCard(code, terminal.getbReaderID()); terminal.setBarcodeNew(false); } terminal.setBarcodeReader(""); } else { terminal.setBarcodeReader(terminal.getBarcodeReader() + event.getText()); System.out.println(terminal.getBarcodeReader()); } } }); }
@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); }); }
private void update() { stage.setX(display.getX()); stage.setY(display.getY()); stage.setWidth(display.getWidth()); stage.setHeight(display.getHeight()); currentLayout.update(); lastUpdate = Calendar.getInstance().getTimeInMillis(); }
/** * maximized the given stage * * @param primaryStage */ public static void maximize(Stage primaryStage) { Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); primaryStage.setX(bounds.getMinX()); primaryStage.setY(bounds.getMinY()); primaryStage.setWidth(bounds.getWidth()); primaryStage.setHeight(bounds.getHeight()); }
@Override public void start(Stage stage) throws Exception { StackPane root = new StackPane(); Scene scene = new Scene(root, Color.LINEN); stage.setWidth(300); stage.setHeight(300); stage.setScene(scene); stage.show(); configureForm(root); }
@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); }
/** 最大化、最大化解除を行う */ public void toogleMaximized() { final Screen screen = Screen.getScreensForRectangle(stage.getX(), stage.getY(), 1, 1).get(0); if (maximized) { maximized = false; if (backupWindowBounds != null) { stage.setX(backupWindowBounds.getMinX()); stage.setY(backupWindowBounds.getMinY()); stage.setWidth(backupWindowBounds.getWidth()); stage.setHeight(backupWindowBounds.getHeight()); } } else { maximized = true; backupWindowBounds = new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()); stage.setX(screen.getVisualBounds().getMinX()); stage.setY(screen.getVisualBounds().getMinY()); stage.setWidth(screen.getVisualBounds().getWidth()); stage.setHeight(screen.getVisualBounds().getHeight()); } }
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()); }
public static void subWindow(String title, Parent parentControl) { Stage stage = new Stage(); Scene scene = new Scene(parentControl); CloseWindowOnEscape.apply(scene, stage); stage.setScene(scene); stage.setWidth(800); stage.setHeight(600); stage.setTitle(title); stage.show(); }
@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(); }
@Override public void start(Stage stage) throws Exception { // TODO Auto-generated method stub primaryStage = stage; primaryStage.setResizable(true); primaryStage.setHeight(600); primaryStage.setWidth(600); primaryStage.setTitle("Jeet Test tool"); mainView = new ProfessorMainViewUI(600, 600); mainView.performFinalSetup("loginView", 0); primaryStage.setScene(mainView); primaryStage.show(); }
@Override public void start(Stage stage) throws Exception { Group group = new Group(); Scene scene = new Scene(group); scene.setFill(Color.GREY); for (int i = 0; i <= 27; i++) { Sector sector = new Sector(20 * i, 20 * i, 10 * i, 20 * i); group.getChildren().add(sector); } stage.setTitle("Hello, SectorApplication!"); stage.setScene(scene); stage.setWidth(600); stage.setHeight(620); stage.show(); }
@Override public void start(Stage primaryStage) throws Exception { root = new Pane((Pane) createContent()); // from game menu root.setPrefSize(windowWidth, windowHeight); gameMenu = new BlackjackMain.GameMenu(); gameMenu.setVisible(true); root.getChildren().addAll(gameMenu); // root.setStyle("-fx-background-image: url('res/images/casino.jpg')"); Scene scene = new Scene(root); scene.setOnKeyPressed( event -> { if (event.getCode() == KeyCode.ESCAPE) { if (!gameMenu.isVisible()) { FadeTransition ft = new FadeTransition(Duration.seconds(0.5), gameMenu); ft.setFromValue(0); ft.setToValue(1); gameMenu.setVisible(true); ft.play(); } else { FadeTransition ft = new FadeTransition(Duration.seconds(0.5), gameMenu); ft.setFromValue(1); ft.setToValue(0); ft.setOnFinished(evt -> gameMenu.setVisible(false)); ft.play(); } } }); // resize(primaryStage); primaryStage.setScene(scene); primaryStage.show(); // primaryStage.setScene(new Scene(createContent())); primaryStage.setWidth(800); primaryStage.setHeight(600); primaryStage.setResizable(false); primaryStage.setTitle("BlackJack"); primaryStage.show(); }
@Override public void start(Stage t) { primaryStage = t; t.setScene(new Scene(new Group())); t.setWidth(100); t.setHeight(100); t.show(); Thread.currentThread() .setUncaughtExceptionHandler( (t2, e) -> { System.out.println("Exception caught: " + e); System.out.flush(); exception = e; }); startupLatch.countDown(); }
@InvokableAction( name = "Resize window", category = "general", description = "Resize the screen to 1x/1.5x/2x/3x video size", alternatives = "Adjust screen;Adjust window size;Adjust aspect ratio;Fix screen;Fix window size;Fix aspect ratio;Correct aspect ratio;", defaultKeyMapping = {"ctrl+shift+a"}) public static void scaleIntegerRatio() { Platform.runLater( () -> { JaceApplication.getApplication().primaryStage.setFullScreen(false); size++; if (size > 3) { size = 0; } int width = 0, height = 0; switch (size) { case 0: // 1x width = 560; height = 384; break; case 1: // 1.5x width = 840; height = 576; break; case 2: // 2x width = 560 * 2; height = 384 * 2; break; case 3: // 3x (retina) 2880x1800 width = 560 * 3; height = 384 * 3; break; default: // 2x width = 560 * 2; height = 384 * 2; } Stage stage = JaceApplication.getApplication().primaryStage; double vgap = stage.getScene().getY(); double hgap = stage.getScene().getX(); stage.setWidth(hgap * 2 + width); stage.setHeight(vgap + height); }); }
/** 設定値からウインドウの状態を復元する。 */ public void loadWindowState() { IrisPreferences preferences = new IrisPreferences(); stage.setHeight(preferences.getDouble(IrisPreferences.WINDOW_HEIGHT, 600f)); stage.setWidth(preferences.getDouble(IrisPreferences.WINDOW_WIDTH, 900f)); double[] div1 = new double[1]; div1[0] = preferences.getDouble(IrisPreferences.WINDOW_DIVIDER_POSITION1, 0.3f); leftSplitPane.setDividerPositions(div1); double[] div2 = new double[1]; div2[0] = preferences.getDouble(IrisPreferences.WINDOW_DIVIDER_POSITION2, 0.5f); rightSplitPane.setDividerPositions(div2); log.debug( "ウインドウサイズ復元 width=" + preferences.getDouble(IrisPreferences.WINDOW_WIDTH, 600f) + " height=" + preferences.getDouble(IrisPreferences.WINDOW_HEIGHT, 900f) + " split1=" + preferences.getDouble(IrisPreferences.WINDOW_DIVIDER_POSITION1, 0.3f) + " split2=" + preferences.getDouble(IrisPreferences.WINDOW_DIVIDER_POSITION2, 0.5f)); }
private void stateLoop() { switch (currentState) { case MainMenu: // adds a new menu and initializes its components mainState = new MainMenu(this); mainState.start(); break; default: break; } // set Stage attributes stage.setTitle("Finding Ataraxy"); stage.setWidth(Screen_Width); stage.setHeight(Screen_Height); stage.setScene(scene); // stage.getStyle(); stage.sizeToScene(); stage.show(); createKeyInputHandling(); createMouseInputHandling(); }
@Override public void start(final Stage stage) { try { palco = stage; page = FXMLLoader.load(Login.class.getResource("../view/login/login.fxml")); cena = new Scene(page); stage.initStyle(StageStyle.UNDECORATED); stage.setX(windows.getMinX()); stage.setY(windows.getMinY()); stage.setWidth(windows.getWidth()); stage.setHeight(windows.getHeight()); stage.getIcons().addAll(new Image(Login.class.getResourceAsStream("icone.png"))); stage.setScene(cena); stage.show(); } catch (Exception ex) { System.out.println("Erro ao inicializar aplicação!" + ex); } }
public static void displaySimple(String title, String message) { Stage window = new Stage(); window.initModality(Modality.APPLICATION_MODAL); window.setTitle(title); window.setWidth(450); window.setHeight(200); Label label = new Label(); label.setWrapText(true); label.setText(message); label.setTextAlignment(TextAlignment.CENTER); Button closeButton = new Button("Close"); closeButton.setOnAction(e -> window.close()); VBox layout = new VBox(20); layout.getChildren().addAll(label, closeButton); layout.setAlignment(Pos.CENTER); Scene scene = new Scene(layout); window.setScene(scene); window.showAndWait(); }
public static boolean displayConfirmation() { Stage window = new Stage(); window.initModality(Modality.APPLICATION_MODAL); window.setTitle("Exit?"); window.setWidth(300); window.setHeight(250); Label label = new Label(); label.setWrapText(true); label.setText("Are you sure you want to quit?"); label.setTextAlignment(TextAlignment.CENTER); label.setPadding(new Insets(20, 20, 20, 20)); Button yesButton = new Button("Yes"); yesButton.setOnAction( e -> { yesNo = true; window.close(); }); Button noButton = new Button("No"); noButton.setOnAction( e -> { yesNo = false; window.close(); }); VBox layout = new VBox(20); layout.getChildren().addAll(label, yesButton, noButton); layout.setAlignment(Pos.CENTER); Scene scene = new Scene(layout); window.setScene(scene); window.showAndWait(); return yesNo; }
/** Nastaví šířku nového okna. */ public ScreenBuilder setWidth(double width) { stage.setWidth(width); return this; }