当前位置: 首页>>代码示例>>Java>>正文


Java Screen.getBounds方法代码示例

本文整理汇总了Java中javafx.stage.Screen.getBounds方法的典型用法代码示例。如果您正苦于以下问题:Java Screen.getBounds方法的具体用法?Java Screen.getBounds怎么用?Java Screen.getBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.stage.Screen的用法示例。


在下文中一共展示了Screen.getBounds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: centerDialogOnScreen

import javafx.stage.Screen; //导入方法依赖的package包/类
/**
     * Utility method to center a Dialog/Alert on the middle of the current
     * screen. Used to workaround a "bug" with the current version of JavaFX (or
     * the SWT/JavaFX embedding?) where alerts always show on the primary
     * screen, not necessarily the current one.
     *
     * @param dialog
     *            The dialog to reposition. It must be already shown, or else
     *            this will do nothing.
     * @param referenceNode
     *            The dialog should be moved to the same screen as this node's
     *            window.
     */
    public static void centerDialogOnScreen(Dialog<?> dialog, Node referenceNode) {
        Window window = referenceNode.getScene().getWindow();
        if (window == null) {
            return;
        }
        Rectangle2D windowRectangle = new Rectangle2D(window.getX(), window.getY(), window.getWidth(), window.getHeight());

        List<Screen> screens = Screen.getScreensForRectangle(windowRectangle);
        Screen screen = screens.stream()
                .findFirst()
                .orElse(Screen.getPrimary());

        Rectangle2D screenBounds = screen.getBounds();
        dialog.setX((screenBounds.getWidth() - dialog.getWidth()) / 2 + screenBounds.getMinX());
//        dialog.setY((screenBounds.getHeight() - dialog.getHeight()) / 2 + screenBounds.getMinY());
    }
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:30,代码来源:JfxUtils.java

示例2: getDesktopSize

import javafx.stage.Screen; //导入方法依赖的package包/类
static Rectangle2D getDesktopSize() {
	Rectangle2D rect = Screen.getPrimary().getBounds();
	double minX = rect.getMinX(), minY = rect.getMinY();
	double maxX = rect.getMaxX(), maxY = rect.getMaxY();
	for (Screen screen : Screen.getScreens()) {
		Rectangle2D screenRect = screen.getBounds();
		if (minX > screenRect.getMinX()) {
			minX = screenRect.getMinX();
		}
		if (minY > screenRect.getMinY()) {
			minY = screenRect.getMinY();
		}
		if (maxX < screenRect.getMaxX()) {
			maxX = screenRect.getMaxX();
		}
		if (maxY < screenRect.getMaxY()) {
			maxY = screenRect.getMaxY();
		}
	}
	return new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:22,代码来源:OverlayStage.java

示例3: fixPosition

import javafx.stage.Screen; //导入方法依赖的package包/类
private void fixPosition() {
    Window w = dialog.getOwner();
    Screen s = com.sun.javafx.util.Utils.getScreen(w);
    Rectangle2D sb = s.getBounds();
    double xR = w.getX() + w.getWidth();
    double xL = w.getX() - dialog.getWidth();
    double x, y;
    if (sb.getMaxX() >= xR + dialog.getWidth()) {
        x = xR;
    } else if (sb.getMinX() <= xL) {
        x = xL;
    } else { 
        x = Math.max(sb.getMinX(), sb.getMaxX() - dialog.getWidth());
    }
    y = Math.max(sb.getMinY(), Math.min(sb.getMaxY() - dialog.getHeight(), w.getY()));
    dialog.setX(x);
    dialog.setY(y);
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:19,代码来源:CustomDialog.java

示例4: start

import javafx.stage.Screen; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
    this.primaryStage = primaryStage;

    Screen screen = Screen.getPrimary();

    Rectangle2D screenBounds = screen.getBounds();

    primaryStage.setWidth(screenBounds.getWidth() * 0.95);
    primaryStage.setHeight(screenBounds.getHeight() * 0.90);

    primaryStage.setMaximized(false);

    homeMenuScreen = HomeMenuScreen.newInstance(this, ConfigurationBuilder.createFromPropertiesResource().build());
    homeMenuScreen.setUpOnStage(primaryStage);

    primaryStage.centerOnScreen();

    primaryStage.setFullScreen(true);
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:21,代码来源:GazePlay.java

示例5: setArenaScreenOrigin

import javafx.stage.Screen; //导入方法依赖的package包/类
private void setArenaScreenOrigin(Screen screen) {
	final double dpiScaleFactor = ShootOFFController.getDpiScaleFactorForScreen();
	final Rectangle2D arenaScreenBounds = screen.getBounds();
	arenaScreenOrigin = new Point2D(arenaScreenBounds.getMinX() * dpiScaleFactor,
			arenaScreenBounds.getMinY() * dpiScaleFactor);

	logger.debug("Set arenaScreenOrigin to {}", arenaScreenOrigin);
}
 
开发者ID:phrack,项目名称:ShootOFF,代码行数:9,代码来源:ProjectorArenaPane.java


注:本文中的javafx.stage.Screen.getBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。