javafx.stage.Window.getHeight()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中javafx.stage.Window.getHeight()方法的一些代码示例,展示了Window.getHeight()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getHeight()方法的具体详情如下:
包路径:javafx.stage.Window
类名称:Window
方法名:getHeight

Window.getHeight介绍

暂无

代码示例

代码示例来源:origin: jfoenixadmin/JFoenix

@Override
protected double computePrefHeight(double width) {
  Window owner = getOwner();
  if (owner != null) {
    return owner.getHeight();
  } else {
    return super.computePrefHeight(width);
  }
}

代码示例来源:origin: com.jfoenix/jfoenix

@Override
protected double computePrefHeight(double width) {
  Window owner = getOwner();
  if (owner != null) {
    return owner.getHeight();
  } else {
    return super.computePrefHeight(width);
  }
}

代码示例来源:origin: org.jfxtras/jfxtras-common

/**
 * Determine the pixels-per-inch of the screen we are on
 * @return
 */
double determinePPI() {
  if (ppi != null) {
    return ppi;
  }
  
  // Use command line value
  if (System.getProperties().containsKey(PPI_SYSTEM_PROPERTY)) {
    ppi = Double.valueOf(System.getProperty(PPI_SYSTEM_PROPERTY));
    if (getTrace()) System.out.println("Using command line " + PPI_SYSTEM_PROPERTY + "=" + ppi); 
    return ppi;
  }
  
  // determine the DPI factor, so the thresholds become larger on screens with a higher DPI
  ppi = 100.0; // average dpi
  Window window = getScene().getWindow();
  ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(window.getX(), window.getY(), window.getWidth(), window.getHeight());
  if (screensForRectangle.size() > 0) {
    Screen lScreen = screensForRectangle.get(0); // we just use the first screen
    ppi = lScreen.getDpi();
    if (getTrace()) System.out.println("screens of scene: " + screensForRectangle + ", using the first then PPI=" + ppi); 
  }
  return ppi;		
}
Double ppi;

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls

if (w != null && new BoundingBox(w.getX(), w.getY(), w.getWidth(), w.getHeight()).contains(screenX, screenY)) {
  return findNode(w.getScene().getRoot(), screenX, screenY);
  if (!FIND_NODE_EXCLUDE.equals(window.getUserData()) && new BoundingBox(window.getX(), window.getY(), window.getWidth(), window.getHeight()).contains(screenX, screenY)) {
    return findNode(window.getScene().getRoot(), screenX, screenY);

代码示例来源:origin: org.copper-engine/copper-monitoring-client

@Override
public void run() {
 Window dialog = previewPane.getScene().getWindow();
 
 double currWidth = dialog.getWidth();
 double currHeight = dialog.getHeight();
 dialog.setWidth(Math.max(currWidth, 20 + previewPane.getLayoutX() + previewPane.getPrefWidth()));
 dialog.setHeight(20 + currHeight + previewPane.getPrefHeight());
 updatePreview();
}

代码示例来源:origin: org.netbeans.html/net.java.html.boot.fx

@Override
  public void handle(WindowEvent event) {
    Window window = (Window) event.getSource();
    prefs.putDouble("x", window.getX()); // NOI18N
    prefs.putDouble("y", window.getY()); // NOI18N
    prefs.putDouble("width", window.getWidth()); // NOI18N
    prefs.putDouble("height", window.getHeight()); // NOI18N
  }
};

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls

/**
 * Find a node in all windows
 *
 * @param w
 *            the preferred window
 * @param screenX
 *            the screen x
 * @param screenY
 *            the screen y
 * @return the node or <code>null</code>
 */
@SuppressWarnings("deprecation")
public static Node findNode(Window w, double screenX, double screenY) {
  // First check the owner
  if (new BoundingBox(w.getX(), w.getY(), w.getWidth(), w.getHeight()).contains(screenX, screenY)) {
    return findNode(w.getScene().getRoot(), screenX, screenY);
  }
  // FIXME If multiple match take the closest
  Iterator<Window> impl_getWindows = Window.impl_getWindows();
  while (impl_getWindows.hasNext()) {
    Window window = impl_getWindows.next();
    if (!FIND_NODE_EXCLUDE.equals(window.getUserData()) && new BoundingBox(window.getX(), window.getY(), window.getWidth(), window.getHeight()).contains(screenX, screenY)) {
      return findNode(window.getScene().getRoot(), screenX, screenY);
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.html/net.java.html.boot.fx

private void _resize(final double width, final double height) {
  Window window = container.getScene().getWindow();
  // size difference between root node and window depends on OS and Decorations
  double diffY = window.getHeight() - container.getHeight();
  double diffX = window.getWidth() - container.getWidth();
  webView.setMaxWidth(width);
  webView.setMaxHeight(height);
  webView.setMinWidth(width);
  webView.setMinHeight(height);
  javafx.geometry.Rectangle2D screenBounds = Screen.getPrimary().getBounds();
  double scaleX = screenBounds.getWidth() / ( width + diffX );
  double scaleY = screenBounds.getHeight() / ( height + diffY );
  // calculate scale factor if too big for device, the .1 adds some padding
  double scale = Math.min(Math.min(scaleX, scaleY), 1.1) - .1;
  webView.setScaleX(scale);
  webView.setScaleY(scale);
  container.getScene().setRoot(new Group());
  ((Stage)window).setScene(new Scene(container, width * scale, height * scale));
}

代码示例来源:origin: org.tentackle/tentackle-fx

/**
 * Calculates the location of a window so that it will be centered on the screen.
 *
 * @param window the window
 * @return the location (top left corner)
 */
public Point2D determineCenteredLocation(Window window)  {
 Rectangle2D screenSize = Screen.getPrimary().getVisualBounds();
 // align sizes (for computation below)
 double windowWidth = window.getWidth();
 double windowHeight = window.getHeight();
 if (window.getWidth() > screenSize.getWidth())  {
  windowWidth = screenSize.getWidth();
 }
 if (windowHeight > screenSize.getHeight())  {
  windowHeight = screenSize.getHeight();
 }
 return new Point2D((screenSize.getWidth()  - windowWidth) / 2.0,
           (screenSize.getHeight() - windowHeight) / 2.0);
}

代码示例来源:origin: org.controlsfx/controlsfx

public void show(Notifications notification) {
  Window window;
  if (notification.owner == null) {
    /*
     * If the owner is not set, we work with the whole screen.
     */
    Rectangle2D screenBounds = notification.screen.getVisualBounds();
    startX = screenBounds.getMinX();
    startY = screenBounds.getMinY();
    screenWidth = screenBounds.getWidth();
    screenHeight = screenBounds.getHeight();
    window = Utils.getWindow(null);
  } else {
    /*
     * If the owner is set, we will make the notifications popup
     * inside its window.
     */
    startX = notification.owner.getX();
    startY = notification.owner.getY();
    screenWidth = notification.owner.getWidth();
    screenHeight = notification.owner.getHeight();
    window = notification.owner;
  }
  show(window, notification);
}

代码示例来源:origin: org.tentackle/tentackle-fx

/**
 * Calculates the position of a stage on the screen so that
 * it is being display in an optimal manner.
 *
 * @param stage the stage to be positioned on the screen
 * @return the location
 */
public Point2D determinePreferredStageLocation(Stage stage)  {
 Point2D location = new Point2D(stage.getX(), stage.getY());
 if (location.getX() == 0.0 && location.getY() == 0.0) {   // if no position yet
  // place in the middle of the owner if possibe
  Window owner = stage.getOwner();
  if (owner != null) {
   location = new Point2D(owner.getX() + (owner.getWidth() - stage.getWidth()) / 2.0,
               owner.getY() + (owner.getHeight() - stage.getHeight()) / 2.0);
  }
  else  {
   // not much we can do: center it
   location = determineCenteredLocation(stage);
  }
 }
 return determineAlignedStageLocation(stage, location);
}

代码示例来源:origin: io.github.factoryfx/javafxDataEditing

double centerY = owner.getY()+owner.getHeight()/2;
Screen screen = Screen.getScreens().stream().filter(s->s.getBounds().contains(centerX,centerY)).findFirst().orElse(Screen.getPrimary());
Rectangle2D screenBounds = screen.getBounds();

代码示例来源:origin: com.miglayout/miglayout-javafx

/** Checks the parent window/popup if its size is within parameters as set by the LC.
 */
private void adjustWindowSize()
{
  BoundSize wBounds = layoutConstraints.getPackWidth();
  BoundSize hBounds = layoutConstraints.getPackHeight();
  Scene scene = getScene();
  Window window = scene != null ? scene.getWindow() : null;
  if (window == null || wBounds == BoundSize.NULL_SIZE && hBounds == BoundSize.NULL_SIZE)
    return;
  Parent root = scene.getRoot();
  double winWidth = window.getWidth();
  double winHeight = window.getHeight();
  double prefWidth = root.prefWidth(-1);
  double prefHeight = root.prefHeight(-1);
  FXContainerWrapper container = new FXContainerWrapper(root);
  double horIns = winWidth - scene.getWidth();
  double verIns = winHeight - scene.getHeight();
  double targetW = constrain(container, winWidth, prefWidth, wBounds) + horIns;
  double targetH = constrain(container, winHeight, prefHeight, hBounds) + verIns;
  double x = window.getX() - ((targetW - winWidth) * (1 - layoutConstraints.getPackWidthAlign()));
  double y = window.getY() - ((targetH - winHeight) * (1 - layoutConstraints.getPackHeightAlign()));
  window.setX(x);
  window.setY(y);
  window.setWidth(targetW);
  window.setHeight(targetH);
}

代码示例来源:origin: org.loadui/testFx

return pointFor( new BoundingBox( window.getX(), window.getY(), window.getWidth(), window.getHeight() ) );

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls

if( getScene() != null && getScene().getWindow() != null ) {
  Window w = getScene().getWindow();
  getScene().getWindow().setHeight(Util.unsignedConstraintValue(w.getHeight(), getMinHeight(), getMaxHeight()));

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls

if( getScene() != null && getScene().getWindow() != null ) {
  Window w = getScene().getWindow();
  getScene().getWindow().setHeight(Util.unsignedConstraintValue(w.getHeight(), getMinHeight(), getMaxHeight()));

相关文章