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


Java Window.getX方法代码示例

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


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

示例1: centerDialogOnScreen

import javafx.stage.Window; //导入方法依赖的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: press

import javafx.stage.Window; //导入方法依赖的package包/类
@Override
public void press(MouseEvent e) {
  Window window = get();
  if (isEnable() && e.isConsumed() == false && window != null) {
    if (canDrag(new Point2D(e.getSceneX(), e.getSceneY()), window.getX() + window.getWidth(), window.getY() + window.getHeight())) {
      startX = e.getScreenX() - window.getX();
      startY = e.getScreenY() - window.getY();
      e.consume();
      pressed = true;
    }
  }
}
 
开发者ID:XDean,项目名称:JavaFX-EX,代码行数:13,代码来源:DragSupport.java

示例3: showTooltip

import javafx.stage.Window; //导入方法依赖的package包/类
private void showTooltip() {
    if (!comboBox.getTooltip().isShowing()) {
        Window stage = comboBox.getScene().getWindow();
        double posX = stage.getX() +
                comboBox.localToScene(comboBox.getBoundsInLocal()).getMinX() + 4;
        double posY = stage.getY() +
                comboBox.localToScene(comboBox.getBoundsInLocal()).getMinY() - 29;
        comboBox.getTooltip().show(stage, posX, posY);
    }
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:11,代码来源:FilteredComboBoxDecorator.java


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