org.openide.util.Utilities.getUsableScreenBounds()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(154)

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

Utilities.getUsableScreenBounds介绍

[英]Returns the usable area of the screen where applications can place its windows. The method subtracts from the screen the area of taskbars, system menus and the like. The screen this method applies to is the one which is considered current, ussually the one where the current input focus is.
[中]返回应用程序可以放置窗口的屏幕可用区域。该方法从屏幕上减去任务栏、系统菜单等区域。此方法适用于被视为当前的屏幕,通常是当前输入焦点所在的屏幕。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util

/**
 * Returns the usable area of the screen where applications can place its
 * windows.  The method subtracts from the screen the area of taskbars,
 * system menus and the like.  The screen this method applies to is the one
 * which is considered current, ussually the one where the current input
 * focus is.
 *
 * @return the rectangle of the screen where one can place windows
 *
 * @since 2.5
 */
public static Rectangle getUsableScreenBounds() {
  return getUsableScreenBounds(getCurrentGraphicsConfiguration());
}

代码示例来源:origin: org.netbeans.api/org-openide-awt

public static Rectangle getScreenRect() {
    return Utilities.getUsableScreenBounds();
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-util-ui

/**
 * Returns the usable area of the screen where applications can place its
 * windows.  The method subtracts from the screen the area of taskbars,
 * system menus and the like.  The screen this method applies to is the one
 * which is considered current, ussually the one where the current input
 * focus is.
 *
 * @return the rectangle of the screen where one can place windows
 *
 * @since 2.5
 */
public static Rectangle getUsableScreenBounds() {
  return getUsableScreenBounds(getCurrentGraphicsConfiguration());
}

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

/** Tries to resize wizard wisely if needed. Keeps "display inertia" so that
 * wizard is only enlarged, not shrinked, and location is changed only when
 * wizard window exceeds screen bounds after resize.
 */
private void resizeWizard(Window parentWindow, Dimension prevSize) {
  assert SwingUtilities.isEventDispatchThread () : "getComponent() must be called in EQ only.";
  Dimension curSize = data.getIterator(this).current().getComponent().getPreferredSize();
  // only enlarge if needed, don't shrink
  if ((curSize.width > prevSize.width) || (curSize.height > prevSize.height)) {
    Rectangle origBounds = parentWindow.getBounds();
    int newWidth = Math.max(origBounds.width + (curSize.width - prevSize.width), origBounds.width);
    int newHeight = Math.max(origBounds.height + (curSize.height - prevSize.height), origBounds.height);
    Rectangle screenBounds = Utilities.getUsableScreenBounds();
    Rectangle newBounds;
    // don't allow to exceed screen size, center if needed
    if (((origBounds.x + newWidth) > screenBounds.width) || ((origBounds.y + newHeight) > screenBounds.height)) {
      newWidth = Math.min(screenBounds.width, newWidth);
      newHeight = Math.min(screenBounds.height, newHeight);
      newBounds = Utilities.findCenterBounds(new Dimension(newWidth, newHeight));
    } else {
      newBounds = new Rectangle(origBounds.x, origBounds.y, newWidth, newHeight);
    }
    parentWindow.setBounds(newBounds);
    parentWindow.invalidate();
    parentWindow.validate();
    parentWindow.repaint();
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

pack();
Rectangle r = Utilities.getUsableScreenBounds();
int maxW = (r.width * 9) / 10;
int maxH = (r.height * 9) / 10;

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public static Rectangle getScreenRect() {
    return Utilities.getUsableScreenBounds();
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public static Rectangle getScreenRect() {
    return Utilities.getUsableScreenBounds();
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public Rectangle getBounds() {
  return Utilities.getUsableScreenBounds();
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public Rectangle getBounds() {
  return Utilities.getUsableScreenBounds();
}

代码示例来源:origin: in.jlibs/org-openide-util

/**
 * Returns the usable area of the screen where applications can place its
 * windows.  The method subtracts from the screen the area of taskbars,
 * system menus and the like.  The screen this method applies to is the one
 * which is considered current, ussually the one where the current input
 * focus is.
 *
 * @return the rectangle of the screen where one can place windows
 *
 * @since 2.5
 */
public static Rectangle getUsableScreenBounds() {
  return getUsableScreenBounds(getCurrentGraphicsConfiguration());
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

protected Rectangle computePopupBounds(int px,int py,int pw,int ph) {
  Dimension d = list.getPreferredSize();
  Rectangle r = Utilities.getUsableScreenBounds();
  if (pw < d.width) {
    pw = Math.min(d.width, r.width -px);
  }
  if (ph < d.height) {
    ph = Math.min (r.height - py, d.height);
  }
  if (px + pw > r.width - px) {
    px -= r.width - pw;
  }
  Rectangle result = new Rectangle (px, py, pw, ph);
  return result;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/**
 * Returns the usable area of the screen where applications can place its
 * windows.  The method subtracts from the screen the area of taskbars,
 * system menus and the like.  The screen this method applies to is the one
 * which is considered current, ussually the one where the current input
 * focus is.
 * 
 * @return the rectangle of the screen where one can place windows
 * 
 * @since 2.5
 */
public static Rectangle getUsableScreenBounds() {
  return getUsableScreenBounds(getCurrentGraphicsConfiguration());
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/**
 * Returns the usable area of the screen where applications can place its
 * windows.  The method subtracts from the screen the area of taskbars,
 * system menus and the like.  The screen this method applies to is the one
 * which is considered current, ussually the one where the current input
 * focus is.
 * 
 * @return the rectangle of the screen where one can place windows
 * 
 * @since 2.5
 */
public static Rectangle getUsableScreenBounds() {
  return getUsableScreenBounds(getCurrentGraphicsConfiguration());
}

代码示例来源:origin: org.gephi/ui-components

private void resizePopup() {
  popupWindow.pack();
  Point point = new Point(0, 0);
  SwingUtilities.convertPointToScreen(point, ancestor);
  Dimension dim = popupWindow.getSize();
  Rectangle usableRect = Utilities.getUsableScreenBounds();
  int sepShift = 0;
  Point loc = new Point(point.x + ancestor.getSize().width - dim.width - sepShift - 5 * 2, point.y - dim.height - 5);
  if (!usableRect.contains(loc)) {
    loc = new Point(loc.x, point.y + 5 + ancestor.getSize().height);
  }
  popupWindow.setLocation(loc);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf

private static Point fitToScreen( int x, int y, int altHeight ) {
  
  Rectangle screen = org.openide.util.Utilities.getUsableScreenBounds();
      
  Point p = new Point( x, y );
  
  // Adjust the x postition if necessary
  if ( ( p.x + popupWindow.getWidth() ) > ( screen.x + screen.width - X_INSET ) ) {
    p.x = screen.x + screen.width - X_INSET - popupWindow.getWidth(); 
  }
  
  // Adjust the y position if necessary
  if ( ( p.y + popupWindow.getHeight() ) > ( screen.y + screen.height - X_INSET ) ) {
    p.y = p.y - popupWindow.getHeight() - altHeight;
  }
  
  return p;     
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

private static Point fitToScreen(int x, int y, int altHeight) {
  Rectangle screen = org.openide.util.Utilities.getUsableScreenBounds();
  Point p = new Point(x, y);
  // Adjust the x postition if necessary
  if ((p.x + popupWindow.getWidth()) > (screen.x + screen.width - X_INSET)) {
    p.x = screen.x + screen.width - X_INSET - popupWindow.getWidth();
  }
  // Adjust the y position if necessary
  if ((p.y + popupWindow.getHeight()) > (screen.y + screen.height - X_INSET)) {
    p.y = p.y - popupWindow.getHeight() - altHeight;
  }
  return p;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

private static Point fitToScreen(int x, int y, int altHeight) {
  Rectangle screen = org.openide.util.Utilities.getUsableScreenBounds();
  Point p = new Point(x, y);
  // Adjust the x postition if necessary
  if ((p.x + popupWindow.getWidth()) > (screen.x + screen.width - X_INSET)) {
    p.x = screen.x + screen.width - X_INSET - popupWindow.getWidth();
  }
  // Adjust the y position if necessary
  if ((p.y + popupWindow.getHeight()) > (screen.y + screen.height - X_INSET)) {
    p.y = p.y - popupWindow.getHeight() - altHeight;
  }
  return p;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils-ui

private static Point fitToScreen(int x, int y, int altHeight) {
  Rectangle screen = org.openide.util.Utilities.getUsableScreenBounds();
  Point p = new Point(x, y);
  // Adjust the x postition if necessary
  if ((p.x + popupWindow.getWidth()) > (screen.x + screen.width - X_INSET)) {
    p.x = screen.x + screen.width - X_INSET - popupWindow.getWidth();
  }
  // Adjust the y position if necessary
  if ((p.y + popupWindow.getHeight()) > (screen.y + screen.height - X_INSET)) {
    p.y = p.y - popupWindow.getHeight() - altHeight;
  }
  return p;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-io

private static Point fitToScreen( int x, int y, int altHeight ) {
  
  Rectangle screen = org.openide.util.Utilities.getUsableScreenBounds();
      
  Point p = new Point( x, y );
  
  // Adjust the x postition if necessary
  if ( ( p.x + popupWindow.getWidth() ) > ( screen.x + screen.width - X_INSET ) ) {
    p.x = screen.x + screen.width - X_INSET - popupWindow.getWidth(); 
  }
  
  // Adjust the y position if necessary
  if ( ( p.y + popupWindow.getHeight() ) > ( screen.y + screen.height - X_INSET ) ) {
    p.y = p.y - popupWindow.getHeight() - altHeight;
  }
  
  return p;     
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans

private static Point fitToScreen( int x, int y, int altHeight ) {
  
  Rectangle screen = org.openide.util.Utilities.getUsableScreenBounds();
      
  Point p = new Point( x, y );
  
  // Adjust the x postition if necessary
  if ( ( p.x + popupWindow.getWidth() ) > ( screen.x + screen.width - X_INSET ) ) {
    p.x = screen.x + screen.width - X_INSET - popupWindow.getWidth(); 
  }
  
  // Adjust the y position if necessary
  if ( ( p.y + popupWindow.getHeight() ) > ( screen.y + screen.height - X_INSET ) ) {
    p.y = p.y - popupWindow.getHeight() - altHeight;
  }
  
  return p;     
}

相关文章