Java Code Examples for javafx.stage.Stage#centerOnScreen()
The following examples show how to use
javafx.stage.Stage#centerOnScreen() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomDemo.java From WorkbenchFX with Apache License 2.0 | 6 votes |
@Override public void start(Stage primaryStage) { preferences = new Preferences(); preferencesModule = new PreferencesModule(preferences); Scene myScene = new Scene(initWorkbench()); primaryStage.setTitle("Custom WorkbenchFX Demo"); primaryStage.setScene(myScene); primaryStage.setWidth(1000); primaryStage.setHeight(700); primaryStage.show(); primaryStage.centerOnScreen(); initNightMode(); }
Example 2
Source File: GuiMainPreloader.java From BlockMap with MIT License | 6 votes |
@Override public void start(Stage stage) throws Exception { splashScreen = stage; stage.centerOnScreen(); stage.initStyle(StageStyle.TRANSPARENT); stage.getIcons().add(new Image(getClass().getResourceAsStream("icon.png"))); ImageView icon = new ImageView(getClass().getResource("icon.png").toString()); icon.setFitWidth(SPLASH_WIDTH); icon.setPreserveRatio(true); BorderPane parent = new BorderPane(icon); parent.setBackground(Background.EMPTY); Scene scene = new Scene(parent, SPLASH_WIDTH, SPLASH_HEIGHT); scene.setFill(Color.TRANSPARENT); splashScreen.setScene(scene); splashScreen.show(); }
Example 3
Source File: DemoLcd.java From Enzo with Apache License 2.0 | 6 votes |
@Override public void start(Stage stage) { StackPane pane = new StackPane(); pane.setPadding(new Insets(10, 10, 10, 10)); pane.getChildren().setAll(control); Scene scene = new Scene(pane, Color.TRANSPARENT); stage.setTitle("Lcd demo"); stage.centerOnScreen(); //stage.initStyle(StageStyle.UNDECORATED); stage.setScene(scene); stage.show(); timer.start(); calcNoOfNodes(scene.getRoot()); System.out.println(noOfNodes + " Nodes in SceneGraph"); }
Example 4
Source File: Main.java From JavaFX with MIT License | 6 votes |
@Override public void start(Stage primaryStage) throws IOException { Group root = new Group(); // describes the window itself: name, size primaryStage.setTitle(" Aufgabe 10 by John Malc "); primaryStage.setScene(new Scene(root)); // say: center on screen, user can resize, and it will in general exists primaryStage.centerOnScreen(); primaryStage.setResizable(true); primaryStage.show(); // Ellipse alone Ellipse a = new Ellipse(); a.setFill(Color.RED); a.setCenterX(205); a.setCenterY(150); a.setRadiusX(80); a.setRadiusY(30); // shows Ellipse and it will add it to the group root.getChildren().add(new Group(a)); }
Example 5
Source File: App.java From spring-labs with Apache License 2.0 | 6 votes |
@Override public void start(Stage stage) throws Exception { notifyPreloader(new Preloader.StateChangeNotification(Preloader.StateChangeNotification.Type.BEFORE_START)); stage.setTitle(windowTitle); stage.setScene(new Scene(mainLayout)); stage.setResizable(true); stage.centerOnScreen(); stage.show(); }
Example 6
Source File: MainActivity.java From ApkToolPlus with Apache License 2.0 | 6 votes |
/** * 最小化 */ public void minimized() { Stage stage = (Stage) btnMinimized.getScene().getWindow(); if (stage.isMaximized()) { // 重置窗口大小 stage.setMaximized(false); stage.setWidth(Config.WINDOW_WIDTH); stage.setHeight(Config.WINDOW_HEIGHT); stage.centerOnScreen(); // 后台运行 Platform.runLater(() -> { stage.setIconified(true); }); } else { stage.setIconified(true); } }
Example 7
Source File: ViewUtils.java From ApkToolPlus with Apache License 2.0 | 6 votes |
/** * 打开一个新窗口 * * @param fxmlUrl fxml文件的url * @param isShowTitle 是否显示title * @return Stage,如果出现异常返回null */ public static Stage newWindow(URL fxmlUrl, boolean isShowTitle){ try { Stage stage = new Stage(); if (!isShowTitle){ setNoBroder(stage); } // 背景透明 stage.initStyle(StageStyle.TRANSPARENT); Parent layout = FXMLLoader.load(fxmlUrl); Scene scene = new Scene(layout, Color.TRANSPARENT); stage.setScene(scene); // 在屏幕中间 stage.centerOnScreen(); return stage; } catch (IOException e) { e.printStackTrace(); } return null; }
Example 8
Source File: Main.java From JavaFX with MIT License | 5 votes |
@Override public void start(Stage primaryStage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource(UI)); Scene frame = new Scene(root); primaryStage.isResizable(); primaryStage.setTitle("Bank Business"); primaryStage.setScene(frame); primaryStage.centerOnScreen(); primaryStage.show(); }
Example 9
Source File: FXDemo.java From javamoney-examples with Apache License 2.0 | 5 votes |
public void start(final Stage primaryStage) { try { Scene scene = new Scene(new MainScreen()); primaryStage.setScene(scene); primaryStage.centerOnScreen(); primaryStage.setTitle("JSR 354 JavaMoney - Demo"); // set icon primaryStage.getIcons().add(new Image("/images/javamoney_s.png")); primaryStage.initStyle(StageStyle.DECORATED); primaryStage.show(); } catch (Exception e) { LOGGER.error("Failed to start application.", e); System.exit(-1); } }
Example 10
Source File: Main.java From JavaFX with MIT License | 5 votes |
@Override public void start(Stage primaryStage) throws MalformedURLException, IOException { // icon Image icon = new Image("resources/icon.png"); Parent root = FXMLLoader.load(getClass().getResource("UI.fxml")); TextArea textArea1; ListView list1; Methods cl = new Methods(); String sit = "http://www.google.com/"; // int ado = cl.getResponseCode(sit); String bobob = cl.getImp(cl.getResponseCode(sit)); // then ado Text t = new Text(10, 20, bobob); Group ab = new Group(root); Scene sc = new Scene(root, 600, 330); primaryStage.setScene(sc); primaryStage.setTitle("Maly Test"); primaryStage.getIcons().add(icon); primaryStage.setResizable(true); primaryStage.centerOnScreen(); primaryStage.show(); }
Example 11
Source File: MainMenu.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public void setMonitor(Stage stage) { // Issue: how do we tweak mars-sim to run on the "active" monitor as chosen by // user ? // "active monitor is defined by whichever computer screen the mouse pointer is // or where the command console that starts mars-sim. // by default MSP runs on the primary monitor (aka monitor 0 as reported by // windows os) only. // see // http://stackoverflow.com/questions/25714573/open-javafx-application-on-active-screen-or-monitor-in-multi-screen-setup/25714762#25714762 // AnchorPane anchor = null; // if (root == null) { // anchor = new AnchorPane(); // anchor.setPrefWidth(WIDTH); // anchor.setPrefHeight(HEIGHT); // } StartUpLocation startUpLoc = new StartUpLocation(WIDTH, HEIGHT); double xPos = startUpLoc.getXPos(); double yPos = startUpLoc.getYPos(); // Set Only if X and Y are not zero and were computed correctly // ObservableList<Screen> screens = Screen.getScreensForRectangle(xPos, yPos, 1, // 1); // ObservableList<Screen> screens = Screen.getScreens(); // System.out.println("# of monitors : " + screens.size()); if (xPos != 0 && yPos != 0) { stage.setX(xPos); stage.setY(yPos); // System.out.println("Monitor 2: x : " + xPos + " y : " + yPos); } else { // System.out.println("calling centerOnScreen()"); // System.out.println("Monitor 1: x : " + xPos + " y : " + yPos); } stage.centerOnScreen(); }
Example 12
Source File: CalculatorFX.java From JavaFX-Tutorial-Codes with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("/genuinecoder/main/calculator.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.centerOnScreen(); stage.setTitle("Genuine Coder"); stage.show(); }
Example 13
Source File: AppStarter.java From PreferencesFX with Apache License 2.0 | 5 votes |
@Override public void start(Stage primaryStage) { TabPane tabPane = new TabPane(); Pane[] examples = new Pane[]{new StandardExample(), new InternationalizedExample(), new OneCategoryExample(), new ExtendedExample(),new NodeExample()}; for(Pane pane : examples) tabPane.getTabs().add(new Tab(pane.getClass().getSimpleName().replace("Example", ""), pane)); Scene myScene = new Scene(tabPane); primaryStage.setTitle("PreferencesFX Demo"); primaryStage.setScene(myScene); primaryStage.setWidth(1000); primaryStage.setHeight(700); primaryStage.show(); primaryStage.centerOnScreen(); }
Example 14
Source File: ExtendedDemo.java From WorkbenchFX with Apache License 2.0 | 5 votes |
@Override public void start(Stage primaryStage) { preferences = new Preferences(); Scene myScene = new Scene(initWorkbench()); primaryStage.setTitle("Extended WorkbenchFX Demo"); primaryStage.setScene(myScene); primaryStage.setWidth(1000); primaryStage.setHeight(700); primaryStage.show(); primaryStage.centerOnScreen(); initNightMode(); }
Example 15
Source File: SingleModuleDemo.java From WorkbenchFX with Apache License 2.0 | 5 votes |
@Override public void start(Stage primaryStage) { Scene myScene = new Scene(initWorkbench()); primaryStage.setTitle("Single Module WorkbenchFX Demo"); primaryStage.setScene(myScene); primaryStage.setWidth(1000); primaryStage.setHeight(700); primaryStage.show(); primaryStage.centerOnScreen(); }
Example 16
Source File: SimpleDemo.java From WorkbenchFX with Apache License 2.0 | 5 votes |
@Override public void start(Stage primaryStage) { Scene myScene = new Scene(initWorkbench()); primaryStage.setTitle("Simple WorkbenchFX Demo"); primaryStage.setScene(myScene); primaryStage.setWidth(1000); primaryStage.setHeight(700); primaryStage.show(); primaryStage.centerOnScreen(); // open calendar module by default workbench.openModule(calendarModule); }
Example 17
Source File: WelcomeWizard.java From Lipi with MIT License | 4 votes |
public static void openDirBlog(File blogDir, Stage primaryStage) { if (blogDir != null) { try { primaryStage.close(); String selectedDirPath = blogDir.getCanonicalPath(); //history is saved WelcomeWizard.storeBlogHistory(selectedDirPath); TomlConfig tomlConfig = new TomlConfig(selectedDirPath + File.separator + "config.toml"); primaryStage.setTitle("Blog Dashboard: " + tomlConfig.getTomlMap().get("title").toString() + " - Lipi"); Stage editorStage = new Stage(); editorStage.setTitle("Lipi Post Editor"); TabbedHMDPostEditor t = new TabbedHMDPostEditor(editorStage); t.getStylesheets().add(Paths.get("res/material.css").toAbsolutePath().toUri().toString()); t.getStylesheets().add(Paths.get("res/custom.css").toAbsolutePath().toUri().toString()); editorStage.setScene(new Scene(t)); editorStage.getIcons().add( new Image(Paths.get("res/lipi-hmdeditor-icon.png").toAbsolutePath().toUri().toString()) ); DashboardMain mainDashboard = new DashboardMain(selectedDirPath, t); VBox holder = new VBox(); // holder.setMinHeight(680); holder.setMinWidth(1000); holder.getChildren().add(mainDashboard); holder.getStylesheets().add(Paths.get("res/material.css").toAbsolutePath().toUri().toString()); holder.getStylesheets().add(Paths.get("res/custom.css").toAbsolutePath().toUri().toString()); Scene scene = new Scene(holder); primaryStage.setScene(scene); // primaryStage.setMinHeight(680); primaryStage.setMinWidth(1000); primaryStage.show(); primaryStage.centerOnScreen(); } catch (IOException e) { ExceptionAlerter.showException(e); e.getMessage(); } } }
Example 18
Source File: Main.java From ApkToolPlus with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) throws Exception{ // 设置应用图标 ViewUtils.setWindowIcon(stage, ClassUtils.getResourceAsURL("res/white_icon/white_icon_Plus.png")); // 无边框 ViewUtils.setNoBroder(stage); // 设置标题 stage.setTitle("ApkToolPlus"); // 背景透明 stage.initStyle(StageStyle.TRANSPARENT); // 设置透明度 //stage.setOpacity(0.8); // 大小不可变 stage.setResizable(false); // main ui StackPane root = new StackPane(); AnchorPane layout = FXMLLoader.load(MainActivity.class.getResource("main.fxml")); layout.setBackground(Background.EMPTY); root.getChildren().add(layout); // 设置根节点 Global.setRoot(root); Scene scene = new Scene(root, Config.WINDOW_WIDTH, Config.WINDOW_HEIGHT, Color.TRANSPARENT); stage.setScene(scene); // test // Loading loading = new Loading(ClassUtils.getResourceAsURL("res/gif/loading.gif")); // loading.setMessage("正在加载,请稍候..."); // root.getChildren().add(loading); // loading.lauchTimeoutTimer(2000); // 在屏幕中间 stage.centerOnScreen(); // 设置拖拽事件 ViewUtils.registerDragEvent(stage,root); stage.show(); // 恢复上次打开页面 Integer lastPageIndex = Integer.parseInt(Config.get(Config.kLastPageIndex, "0")); MainActivity.getInstance().pages.setCurrentPageIndex(lastPageIndex); }
Example 19
Source File: LogFX.java From LogFX with GNU General Public License v3.0 | 4 votes |
@Override @MustCallOnJavaFXThread public void start( Stage primaryStage ) { this.stage = primaryStage; setPrimaryStage( primaryStage ); setIconsOn( primaryStage ); MenuBar menuBar = new MenuBar(); menuBar.useSystemMenuBarProperty().set( true ); menuBar.getMenus().addAll( fileMenu(), viewMenu(), helpMenu() ); VBox mainBox = new VBox( 0 ); logsPane.prefHeightProperty().bind( mainBox.heightProperty() ); mainBox.getChildren().addAll( menuBar, logsPane.getNode() ); Platform.runLater( () -> updateBottomMessagePane( mainBox ) ); config.filtersEnabledProperty().addListener( ( o ) -> updateBottomMessagePane( mainBox ) ); root.getChildren().addAll( mainBox, overlay ); Scene scene = new Scene( root, 800, 600, Color.RED ); root.prefHeightProperty().bind( scene.heightProperty() ); root.prefWidthProperty().bind( scene.widthProperty() ); mainBox.prefHeightProperty().bind( scene.heightProperty() ); mainBox.prefWidthProperty().bind( scene.widthProperty() ); primaryStage.setScene( scene ); primaryStage.centerOnScreen(); primaryStage.setTitle( TITLE ); primaryStage.show(); primaryStage.setOnHidden( event -> { logsPane.close(); taskRunner.shutdown(); } ); Platform.runLater( () -> { log.debug( "Setting divider positions to {}", config.getPaneDividerPositions() ); logsPane.setDividerPositions( config.getPaneDividerPositions() ); logsPane.panesDividersProperty().addListener( observable -> config.getPaneDividerPositions().setAll( logsPane.getSeparatorsPositions() ) ); } ); FxUtils.setupStylesheet( scene ); }
Example 20
Source File: JfxApplication.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
@Override @FxThread public void start(@NotNull Stage stage) throws Exception { JfxApplication.instance = this; this.stage = stage; addWindow(stage); try { // initialize javaFX events in javaFX thread. ArrayFactory.asArray(ComboBoxBase.ON_SHOWN); var resourceManager = ResourceManager.getInstance(); resourceManager.reload(); var initializationManager = InitializationManager.getInstance(); initializationManager.onBeforeCreateJavaFxContext(); var pluginManager = PluginManager.getInstance(); pluginManager.handlePlugins(editorPlugin -> editorPlugin.register(CssRegistry.getInstance())); LogView.getInstance(); SvgImageLoaderFactory.install(); ImageIO.read(getClass().getResourceAsStream("/ui/icons/test/test.jpg")); var icons = stage.getIcons(); icons.add(new Image("/ui/icons/app/256x256.png")); icons.add(new Image("/ui/icons/app/128x128.png")); icons.add(new Image("/ui/icons/app/96x96.png")); icons.add(new Image("/ui/icons/app/64x64.png")); icons.add(new Image("/ui/icons/app/48x48.png")); icons.add(new Image("/ui/icons/app/32x32.png")); icons.add(new Image("/ui/icons/app/24x24.png")); icons.add(new Image("/ui/icons/app/16x16.png")); var config = EditorConfig.getInstance(); stage.initStyle(StageStyle.DECORATED); stage.setMinHeight(600); stage.setMinWidth(800); stage.setWidth(config.getScreenWidth()); stage.setHeight(config.getScreenHeight()); stage.setMaximized(config.isMaximized()); stage.setTitle(Config.TITLE); stage.show(); if (!stage.isMaximized()) { stage.centerOnScreen(); } stage.widthProperty().addListener((observable, oldValue, newValue) -> { if (stage.isMaximized()) return; config.setScreenWidth(newValue.intValue()); }); stage.heightProperty().addListener((observable, oldValue, newValue) -> { if (stage.isMaximized()) return; config.setScreenHeight(newValue.intValue()); }); stage.maximizedProperty() .addListener((observable, oldValue, newValue) -> config.setMaximized(newValue)); buildScene(); } catch (Throwable e) { LOGGER.error(this, e); throw e; } }