Java Code Examples for javafx.stage.Stage#setMaximized()

The following examples show how to use javafx.stage.Stage#setMaximized() . 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: Main.java    From cute-proxy with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    VBox root = FXMLLoader.load(getClass().getResource("/fxml/main.fxml"));
    Scene scene = new Scene(root);
    stage.setTitle("Cute Proxy");
    stage.setMaximized(true);
    stage.getIcons().add(new Image(this.getClass().getResourceAsStream("/icon.png")));
    stage.setScene(scene);

    stage.show();
    root.requestFocus();

    stage.setOnCloseRequest(e -> {
        CloseHooks.executeTasks();
        Platform.exit();
    });
}
 
Example 2
Source File: MainActivity.java    From ApkToolPlus with Apache License 2.0 6 votes vote down vote up
/**
 * 最小化
 */
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 3
Source File: ResponderApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
  Pane root = (Pane) FXMLLoader.load(getClass().getResource("layout_responder_app.fxml"));
  Scene scene = new Scene(root, -1, -1);
  scene.getStylesheets().add("main.css");
  stage.setTitle("Responder App");
  stage.initStyle(StageStyle.TRANSPARENT);
  stage.setScene(scene);
  stage.setMaximized(true);
  stage.show();
}
 
Example 4
Source File: MonitorApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
  Parent root = FXMLLoader.load(getClass().getResource("/fxml/Monitor.fxml"));
  Scene scene = new Scene(root);
  stage.setTitle("Fire Monitor");
  stage.setScene(scene);
  stage.setMaximized(true);
  stage.show();
}
 
Example 5
Source File: StageModeTest.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void valueForDefault() {
    Stage stage = new Stage();
    Scene scene = new Scene(new HBox());
    stage.setScene(scene);
    stage.setMaximized(false);
    stage.setIconified(false);
    assertEquals(StageMode.DEFAULT, StageMode.valueFor(stage));
}
 
Example 6
Source File: StageModeTest.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void valueForMaximized() {
    Stage stage = new Stage();
    Scene scene = new Scene(new HBox());
    stage.setScene(scene);
    stage.setMaximized(true);
    assertEquals(StageMode.MAXIMIZED, StageMode.valueFor(stage));
}
 
Example 7
Source File: Application.java    From Augendiagnose with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD",
		justification = "Intentionally write the stage statically")
public final void start(final Stage primaryStage) throws IOException, IllegalAccessException {
	Application.mStage = primaryStage;
	primaryStage.setTitle(ResourceUtil.getString("app_name"));

	MainController mainController = (MainController) FxmlUtil.getRootFromFxml(FxmlConstants.FXML_MAIN);

	// In case of screen change, ensure that window is not bigger than screen.
	Rectangle2D mainScreen = Screen.getPrimary().getVisualBounds();
	double width = Math.min(mainScreen.getWidth(), PreferenceUtil.getPreferenceDouble(KEY_WINDOW_SIZE_X));
	double height = Math.min(mainScreen.getHeight(), PreferenceUtil.getPreferenceDouble(KEY_WINDOW_SIZE_Y));

	mScene = new Scene(mainController.getRoot(), width, height);

	// Store window size on close.
	primaryStage.setOnCloseRequest(
			new EventHandler<WindowEvent>() {
				@Override
				public void handle(final WindowEvent event) {
					// do not close window.
					event.consume();
					exitAfterConfirmation();
				}
			});

	primaryStage.setScene(mScene);
	primaryStage.setMaximized(PreferenceUtil.getPreferenceBoolean(KEY_WINDOW_MAXIMIZED));
	primaryStage.getIcons().add(new Image("img/Augendiagnose.png"));
	primaryStage.show();

	FxmlUtil.displaySubpage(FxmlConstants.FXML_DISPLAY_PHOTOS, 0, false);

	mHostServices = getHostServices();

	VersioningUtil.checkForNewerVersion(false);
}
 
Example 8
Source File: CameraViewTest.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    
    loadSubScene();
    root.setStyle("-fx-background-color: DEEPSKYBLUE;");
    Scene scene = new Scene(root, 810,610, true, SceneAntialiasing.BALANCED);
    scene.setFill(Color.TRANSPARENT);
           
    stage.setTitle("MiniMapTest");
    stage.setScene(scene);
    //stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();
    stage.setMaximized(true);
    cameraView.startViewing();
}
 
Example 9
Source File: BillBoardBehaviorTest.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws NonInvertibleTransformException {
    
    createSubscene();        
    createCameraView();
    createOverlay();
    
    Scene scene = new Scene(rootPane, 1024, 668);          
    
    stage.setTitle("Billbording Test!");
    stage.setScene(scene);
    stage.setMaximized(true);
    stage.show();                        
    
}
 
Example 10
Source File: UI.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void initUI(Stage stage) {
    apiBox = new Label("-/-");
    apiBox.setPadding(new Insets(10, 10, 5, 15));
    apiBox.setId(IdGenerator.getApiBoxId());

    mainStage = stage;
    stage.setMaximized(false);

    panels = new PanelControl(this, mainStage, prefs);
    guiController = new GUIController(this, panels, apiBox);

    Scene scene = new Scene(createRootNode());

    setupMainStage(scene);
    setupGlobalKeyboardShortcuts(scene);

    screenManager = new ScreenManager(mainStage);
    screenManager.setupStageDimensions(mainStage, panels.getPanelWidth());
    screenManager.setupPositionListener(stage);

    notificationController = new NotificationController(notificationPane);
    notificationPane.setId("notificationPane");

    loadFonts();
    String css = initCSS();
    applyCSS(css, scene);

    setApplicationIcon(stage);
}
 
Example 11
Source File: BaseController.java    From Vert.X-generator with MIT License 5 votes vote down vote up
/**
 * 加载一个页面
 * 
 * @param title
 *          页面标题
 * @param fxmlPage
 *          页面FXML路径
 * @param resize
 *          是否可以窗口最大化
 * @param cache
 *          是否换缓存
 * @return
 */
public BaseController loadFXMLPage(String title, FXMLPage fxmlPage, boolean resize, boolean cache) {
	SoftReference<? extends BaseController> parentNodeRef = cacheNodeMap.get(fxmlPage);
	if (cache && parentNodeRef != null) {
		return parentNodeRef.get();
	}
	URL skeletonResource = Thread.currentThread().getContextClassLoader().getResource(fxmlPage.getFxml());

	FXMLLoader loader = new FXMLLoader(skeletonResource);

	Parent loginNode;
	try {
		loginNode = loader.load();
		BaseController controller = loader.getController();
		dialogStage = new Stage();
		dialogStage.setTitle(title);
		dialogStage.getIcons().add(new Image("image/icon.png"));
		dialogStage.initModality(Modality.APPLICATION_MODAL);
		dialogStage.initOwner(getPrimaryStage());
		dialogStage.setScene(new Scene(loginNode));
		dialogStage.setMaximized(false);
		dialogStage.setResizable(resize);
		dialogStage.show();
		controller.setDialogStage(dialogStage);
		SoftReference<BaseController> softReference = new SoftReference<>(controller);
		cacheNodeMap.put(fxmlPage, softReference);
		return controller;
	} catch (IOException e) {
		AlertUtil.showErrorAlert(e.getMessage());
	}
	return null;

}
 
Example 12
Source File: MainLauncher.java    From ClusterDeviceControlPlatform with MIT License 5 votes vote down vote up
private void startApp(Stage primaryStage) {
    primaryStage.setTitle("设备模拟客户端");
    primaryStage.setScene(new Scene(MainView.getInstance()));
    primaryStage.setMaximized(true);
    primaryStage.setOnCloseRequest(event -> NettyLauncher.getInstance().shutdown());
    primaryStage.show();
    MainView.getInstance().updateGroupCount(10);
}
 
Example 13
Source File: BaseController.java    From Spring-generator with MIT License 5 votes vote down vote up
/**
 * 加载一个页面
 * 
 * @param title
 *          页面标题
 * @param fxmlPage
 *          页面FXML路径
 * @param resize
 *          是否可以窗口最大化
 * @param cache
 *          是否换缓存
 * @return
 */
public BaseController loadFXMLPage(String title, FXMLPage fxmlPage, boolean resize, boolean cache) {
	SoftReference<? extends BaseController> parentNodeRef = cacheNodeMap.get(fxmlPage);
	if (cache && parentNodeRef != null) {
		return parentNodeRef.get();
	}
	URL skeletonResource = Thread.currentThread().getContextClassLoader().getResource(fxmlPage.getFxml());

	FXMLLoader loader = new FXMLLoader(skeletonResource);

	Parent loginNode;
	try {
		loginNode = loader.load();
		BaseController controller = loader.getController();
		dialogStage = new Stage();
		dialogStage.setTitle(title);
		dialogStage.getIcons().add(new Image("image/icon.png"));
		dialogStage.initModality(Modality.APPLICATION_MODAL);
		dialogStage.initOwner(getPrimaryStage());
		dialogStage.setScene(new Scene(loginNode));
		dialogStage.setMaximized(false);
		dialogStage.setResizable(resize);
		dialogStage.show();
		controller.setDialogStage(dialogStage);
		SoftReference<BaseController> softReference = new SoftReference<>(controller);
		cacheNodeMap.put(fxmlPage, softReference);
		return controller;
	} catch (IOException e) {
		AlertUtil.showErrorAlert(e.getMessage());
	}
	return null;

}
 
Example 14
Source File: FxmlControl.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static void setMaximized(Stage stage, boolean max) {
    stage.setMaximized(max);
    if (max) {
        Rectangle2D primaryScreenBounds = getScreen();
        stage.setX(primaryScreenBounds.getMinX());
        stage.setY(primaryScreenBounds.getMinY());
        stage.setWidth(primaryScreenBounds.getWidth());
        stage.setHeight(primaryScreenBounds.getHeight());
    }
}
 
Example 15
Source File: BankingClientApplication.java    From Software-Architecture-with-Spring-5.0 with MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    LayoutPane layoutPane = new LayoutPane();
    layoutPane.loadScreen("balance", BalanceController.class.getResource("Balance.fxml"));
    layoutPane.loadScreen("login", LoginController.class.getResource("Login.fxml"));

    layoutPane.showScreen("login");

    Scene scene = new Scene(layoutPane);
    scene.getStylesheets().add("bootstrapfx.css");
    primaryStage.setScene(scene);
    primaryStage.setMaximized(true);
    primaryStage.initStyle(StageStyle.TRANSPARENT);
    primaryStage.show();
}
 
Example 16
Source File: ClientMainFrame.java    From Open-Lowcode with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a client mainframe and showing it
 * 
 * @param stage                   javafx application stage
 * @param clientversion           version of the client
 * @param clientversiondate       date of the version of the client
 * @param clientupgradepage       the page to show in case of upgrade
 * @param actionsourcetransformer transformer of widgets sending events to
 *                                action event to their significant parent (e.g.
 *                                tablecell -> tableview)
 * @param pagenodecatalog         list of CPageNodes managed
 * @param urltoconnectto          URL to connect to at start
 * @param nolog                   no logs are shown in the server
 * @param smallicon               URL to the small icon (32x32)
 * @param bigicon                 URL to the big icon (64x64)
 * @param questionmarkicon        URL of the question mark uicon
 * @param cssfile                 URL to the CSS file
 * @throws IOException if any bad happens while setting up the logs
 */
public ClientMainFrame(Stage stage, String clientversion, Date clientversiondate,
		ClientUpgradePageGenerator clientupgradepage, ActionSourceTransformer actionsourcetransformer,
		CPageNodeCatalog pagenodecatalog, String urltoconnectto, boolean nolog, String smallicon, String bigicon,
		String questionmarkicon, String cssfile) throws IOException {
	this.nolog = nolog;
	this.stage = stage;
	this.clientversion = clientversion;
	this.clientversiondate = clientversiondate;
	this.clientupgradepage = clientupgradepage;

	CPageNode.setPageCatelog(pagenodecatalog);
	initiateLog();
	logger.severe("--------------- * * * Open Lowcode client * * * ---------------");
	logger.severe(" * * version="+clientversion+", client built date="+sdf.format(clientversiondate)+"* *");
	// ---------------------------------------- initiates the first tab
	uniqueclientsession = new ClientSession(this, actionsourcetransformer, urltoconnectto, questionmarkicon);
	if (smallicon != null)
		stage.getIcons().add(new Image(smallicon));
	if (bigicon != null)
		stage.getIcons().add(new Image(bigicon));
	Scene scene = new Scene(this.uniqueclientsession.getClientSessionNode(), Color.WHITE);
	if (cssfile != null)
		scene.getStylesheets().add(cssfile);
	stage.setScene(scene);
	stage.setTitle("Open Lowcode client");
	// ---------------------------------------- show the stage
	stage.setMaximized(true);
	this.stage.show();
}
 
Example 17
Source File: JfxApplication.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@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;
    }
}
 
Example 18
Source File: XdatEditor.java    From xdat_editor with MIT License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    this.stage = primaryStage;

    FXMLLoader loader = new FXMLLoader(getClass().getResource("main.fxml"), interfaceResources);
    loader.setClassLoader(getClass().getClassLoader());
    loader.setControllerFactory(param -> new Controller(XdatEditor.this));
    Parent root = loader.load();
    controller = loader.getController();

    primaryStage.setTitle("XDAT Editor");
    primaryStage.setScene(new Scene(root));
    primaryStage.setWidth(Double.parseDouble(windowPrefs().get("width", String.valueOf(primaryStage.getWidth()))));
    primaryStage.setHeight(Double.parseDouble(windowPrefs().get("height", String.valueOf(primaryStage.getHeight()))));
    if (windowPrefs().getBoolean("maximized", primaryStage.isMaximized())) {
        primaryStage.setMaximized(true);
    } else {
        Rectangle2D bounds = new Rectangle2D(
                Double.parseDouble(windowPrefs().get("x", String.valueOf(primaryStage.getX()))),
                Double.parseDouble(windowPrefs().get("y", String.valueOf(primaryStage.getY()))),
                primaryStage.getWidth(),
                primaryStage.getHeight());
        if (Screen.getScreens()
                .stream()
                .map(Screen::getVisualBounds)
                .anyMatch(r -> r.intersects(bounds))) {
            primaryStage.setX(bounds.getMinX());
            primaryStage.setY(bounds.getMinY());
        }
    }
    primaryStage.show();

    Platform.runLater(() -> {
        InvalidationListener listener = observable -> {
            if (primaryStage.isMaximized()) {
                windowPrefs().putBoolean("maximized", true);
            } else {
                windowPrefs().putBoolean("maximized", false);
                windowPrefs().put("x", String.valueOf(Math.round(primaryStage.getX())));
                windowPrefs().put("y", String.valueOf(Math.round(primaryStage.getY())));
                windowPrefs().put("width", String.valueOf(Math.round(primaryStage.getWidth())));
                windowPrefs().put("height", String.valueOf(Math.round(primaryStage.getHeight())));
            }
        };
        primaryStage.xProperty().addListener(listener);
        primaryStage.yProperty().addListener(listener);
        primaryStage.widthProperty().addListener(listener);
        primaryStage.heightProperty().addListener(listener);
    });
    Platform.runLater(this::postShow);
}
 
Example 19
Source File: AboutController.java    From Sword_emulator with GNU General Public License v3.0 4 votes vote down vote up
public static void run() {
    Stage stage = FxUtils.newStage(null, "关于", "about.fxml", null);
    stage.setMaximized(false);
    stage.setResizable(false);
    stage.show();
}
 
Example 20
Source File: ViewUtils.java    From ApkToolPlus with Apache License 2.0 2 votes vote down vote up
/**
 * 最大化
 *
 * @param stage
 */
public static void maximized(Stage stage){
    stage.setMaximized(!stage.isMaximized());
}