java.awt.Window#getHeight ( )源码实例Demo

下面列出了java.awt.Window#getHeight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: nextreports-designer   文件: Show.java
public static void pack
        (Window
                window) {
    Dimension dim = window.getPreferredSize();
    int prefw = dim.width;
    int w = window.getWidth();
    if (w < prefw) {
        w = prefw;
    }
    int prefh = dim.height;
    int h = window.getHeight();
    if (h < prefh) {
        h = prefh;
    }
    window.setSize(w, h);
}
 
源代码2 项目: jpexs-decompiler   文件: View.java
public static void centerScreen(Window f, int screen) {

        GraphicsDevice[] allDevices = getEnv().getScreenDevices();
        int topLeftX, topLeftY, screenX, screenY, windowPosX, windowPosY;

        if (screen < allDevices.length && screen > -1) {
            topLeftX = allDevices[screen].getDefaultConfiguration().getBounds().x;
            topLeftY = allDevices[screen].getDefaultConfiguration().getBounds().y;

            screenX = allDevices[screen].getDefaultConfiguration().getBounds().width;
            screenY = allDevices[screen].getDefaultConfiguration().getBounds().height;
        } else {
            topLeftX = allDevices[0].getDefaultConfiguration().getBounds().x;
            topLeftY = allDevices[0].getDefaultConfiguration().getBounds().y;

            screenX = allDevices[0].getDefaultConfiguration().getBounds().width;
            screenY = allDevices[0].getDefaultConfiguration().getBounds().height;
        }

        windowPosX = ((screenX - f.getWidth()) / 2) + topLeftX;
        windowPosY = ((screenY - f.getHeight()) / 2) + topLeftY;

        f.setLocation(windowPosX, windowPosY);
    }
 
源代码3 项目: rapidminer-studio   文件: BubbleWindow.java
/**
 * method to get to know whether the AbstractButton with the given key is on Screen
 *
 * @param dockableKey
 *            i18nKey of the wanted AbstractButton
 * @return returns 0 if the AbstractButton is on the Screen, 1 if the AbstractButton is on
 *         Screen but the user can not see it with the current settings of the perspective and
 *         -1 if the AbstractButton is not on the Screen.
 */
public static int isButtonOnScreen(final String buttonKey) {
	// find the Button and return -1 if we can not find it
	Component onScreen;
	try {
		onScreen = BubbleWindow.findButton(buttonKey, RapidMinerGUI.getMainFrame());
	} catch (NullPointerException e) {
		return OBJECT_NOT_ON_SCREEN;
	}
	if (onScreen == null) {
		return OBJECT_NOT_ON_SCREEN;
	}
	// detect whether the Button is viewable
	int xposition = onScreen.getLocationOnScreen().x;
	int yposition = onScreen.getLocationOnScreen().y;
	int otherXposition = xposition + onScreen.getWidth();
	int otherYposition = yposition + onScreen.getHeight();
	Window frame = RapidMinerGUI.getMainFrame();
	if (otherXposition <= frame.getWidth() && otherYposition <= frame.getHeight() && xposition > 0 && yposition > 0) {
		return OBJECT_SHOWING_ON_SCREEN;
	} else {
		return OBJECT_NOT_SHOWING;
	}
}
 
源代码4 项目: triplea   文件: Util.java
/** Centers the specified window on the screen. */
public static void center(final Window w) {
  final Dimension screenSize = getScreenSize(w);
  final int screenWidth = screenSize.width;
  final int screenHeight = screenSize.height;
  final int windowWidth = w.getWidth();
  final int windowHeight = w.getHeight();
  if (windowHeight > screenHeight) {
    return;
  }
  if (windowWidth > screenWidth) {
    return;
  }
  final int x = (screenWidth - windowWidth) / 2;
  final int y = (screenHeight - windowHeight) / 2;
  w.setLocation(x, y);
}
 
源代码5 项目: TencentKona-8   文件: FullScreenInsets.java
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
源代码6 项目: jdk8u60   文件: FullScreenInsets.java
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
源代码7 项目: openjdk-jdk8u   文件: FullScreenInsets.java
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
源代码8 项目: openjdk-jdk8u-backup   文件: FullScreenInsets.java
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
源代码9 项目: openjdk-jdk9   文件: FullScreenInsets.java
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
源代码10 项目: openjdk-jdk9   文件: MouseWheelAbsXY.java
private static void test(GraphicsConfiguration gc) throws AWTException {
    final Window frame = new Frame(gc);
    try {
        frame.addMouseWheelListener(e -> {
            wheelX = e.getXOnScreen();
            wheelY = e.getYOnScreen();
            done = true;
        });
        frame.setSize(300, 300);
        frame.setVisible(true);

        final Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.setAutoWaitForIdle(true);
        mouseX = frame.getX() + frame.getWidth() / 2;
        mouseY = frame.getY() + frame.getHeight() / 2;

        robot.mouseMove(mouseX, mouseY);
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseWheel(10);

        validate();
    } finally {
        frame.dispose();
    }
}
 
源代码11 项目: openjdk-8-source   文件: FullScreenInsets.java
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
源代码12 项目: openjdk-8   文件: FullScreenInsets.java
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
源代码13 项目: jdk8u-dev-jdk   文件: FullScreenInsets.java
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
源代码14 项目: littleluck   文件: WindowMouseHandler.java
/**
 *  v1.0.1:修复自定义拖拽区域BUG, 保存游标状态
 */
public void mouseMoved(MouseEvent e)
{
    Window window = (Window)e.getSource();

    int w = window.getWidth();

    int h = window.getHeight();

    Point point = e.getPoint();

    JRootPane rootPane = LuckWindowUtil.getRootPane(window);

    int cursor = 0;

    if(rootPane != null && LuckWindowUtil.isResizable(window))
    {
        cursor = getCursor(w, h, point, rootPane.getInsets());
    }

    if(cursor != Cursor.DEFAULT_CURSOR)
    {
        window.setCursor(Cursor.getPredefinedCursor(cursor));
    }
    else
    {
        window.setCursor(lastCursor);
    }
    
    dragCursor = cursor;
}
 
源代码15 项目: RipplePower   文件: DownloadBlocksDialog.java
public DownloadBlocksDialog(String text, Window parent) {
	super(LSystem.applicationMain, "Download Bitcoin Blocks", Dialog.ModalityType.DOCUMENT_MODAL);
	addWindowListener(HelperWindow.get());
	setIconImage(UIRes.getIcon());
	setResizable(false);
	Dimension dim = new Dimension(parent.getWidth() - 150, parent.getHeight() - 100);
	setPreferredSize(dim);
	setSize(dim);

	statusPanel = new StatusPanel();
	setContentPane(statusPanel);

	addWindowListener(new ApplicationWindowListener());
}
 
源代码16 项目: jdk8u-jdk   文件: FullScreenInsets.java
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
源代码17 项目: Pixelitor   文件: FocusArrowListener.java
/**
 * Shifts the focus in a certain direction.
 *
 * @param dx  the amount to increment x.
 * @param dy  the amount to increment y.
 * @param src the source to traverse from.
 * @return true if another component requested the focus
 * as a result of this method.  This may return false if
 * no suitable component was found to shift focus to.
 * (If you press the right arrow key on the right-most
 * component, for example.)
 */
public static boolean shiftFocus(int dx, int dy, Component src) {
    if (dx == 0 && dy == 0) //this would result in an infinite loop
    {
        throw new IllegalArgumentException("dx (" + dx + ") and (" + dy + ") cannot both be zero");
    }

    Set<Component> focusableComponents = getFocusableComponents(src);

    int x = src.getWidth() / 2;
    int y = src.getHeight() / 2;
    Window window = SwingUtilities.getWindowAncestor(src);
    if (window == null) {
        return false;
    }
    Point p = SwingUtilities.convertPoint(src, x, y, window);

    Component comp = null;
    int windowWidth = window.getWidth();
    int windowHeight = window.getHeight();

    while (p.x > 0 && p.x < windowWidth && p.y > 0 && p.y < windowHeight && (comp == null || comp == src || (comp instanceof JPanel))) {
        p.x += dx;
        p.y += dy;
        comp = SwingUtilities.getDeepestComponentAt(window, p.x, p.y);
        boolean canAcceptFocus = focusableComponents.contains(comp);
        if (comp != null && !canAcceptFocus) {
            comp = null;
        }
    }

    //TODO: implement a more robust searching mechanism instead of the above
    //If a component is below the src, but to the left or right of the center:
    //it should still be detected when you press the down arrow key.

    if (comp != null && comp != src && comp != window && !(comp instanceof JPanel)) {
        comp.requestFocus();
        return true;
    }
    return false;
}
 
源代码18 项目: pumpernickel   文件: FocusArrowListener.java
/**
 * Return the first component available from a collection of candidates that
 * is generally in the direction provided.
 */
public static Component getComponent(int dx, int dy, Component src,
		Collection<Component> candidates) {
	if (dx == 0 && dy == 0) // this would result in an infinite loop
		throw new IllegalArgumentException("dx (" + dx + ") and (" + dy
				+ ") cannot both be zero");

	int x = src.getWidth() / 2;
	int y = src.getHeight() / 2;
	Window window = SwingUtilities.getWindowAncestor(src);
	if (window == null)
		return null;
	Point p = SwingUtilities.convertPoint(src, x, y, window);

	Component comp = null;
	int windowWidth = window.getWidth();
	int windowHeight = window.getHeight();

	Map<Component, Rectangle> candidateWindowBounds = new HashMap<>();
	for (Component candidate : candidates) {
		Point z = SwingUtilities.convertPoint(candidate, new Point(0, 0),
				window);
		Rectangle r = new Rectangle(z.x, z.y, candidate.getWidth(),
				candidate.getHeight());
		candidateWindowBounds.put(candidate, r);
	}

	while (p.x > 0 && p.x < windowWidth && p.y > 0 && p.y < windowHeight
			&& (comp == null || comp == src || (comp instanceof JPanel))) {
		p.x += dx;
		p.y += dy;

		// this mostly works, but it fails when, say, an overlay tooltip is
		// covering up what we want to select:
		// comp = SwingUtilities.getDeepestComponentAt(window, p.x, p.y);

		comp = null;
		for (Entry<Component, Rectangle> entry : candidateWindowBounds
				.entrySet()) {
			if (entry.getValue().contains(p)) {
				comp = entry.getKey();
				break;
			}
		}
		boolean canAcceptFocus = candidates.contains(comp);
		if (comp != null && canAcceptFocus == false)
			comp = null;
	}

	// TODO: implement a more robust searching mechanism instead of the
	// above. If a component is below the src, but to the left or right of
	// the center: it should still be detected when you press the down arrow
	// key.

	return comp;
}
 
源代码19 项目: littleluck   文件: WindowMouseHandler.java
/**
 *  v1.0.1:修复自定义拖拽区域BUG, 增加边界判断
 */
public void mousePressed(MouseEvent e)
{
    Window window = (Window) e.getSource();

    JRootPane root = LuckWindowUtil.getRootPane(window);

    // 不包含窗体装饰直接返回
    if (root == null || root.getWindowDecorationStyle() == JRootPane.NONE)
    {
        return;
    }
    
    if (window != null)
    {
        window.toFront();
    }

    // 如果是单击标题栏, 则标记接下来的拖动事件为移动窗口, 判断当前鼠标是否超出边界
    if (dragArea.contains(e.getPoint())
            && dragCursor == Cursor.DEFAULT_CURSOR)
    {
        if(window instanceof JFrame)
        {
            JFrame frame = (JFrame)window;

            // 如果当前窗体是全屏状态则直接返回
            if(frame.getExtendedState() == JFrame.MAXIMIZED_BOTH)
            {
                return;
            }
        }

        // 设置为可以移动并记录当前坐标
        isMovingWindow = true;

        dragOffsetX = e.getPoint().x;

        dragOffsetY = e.getPoint().y;
    }
    else if(LuckWindowUtil.isResizable(window))
    {
        dragOffsetX = e.getPoint().x;

        dragOffsetY = e.getPoint().y;

        dragWidth = window.getWidth();

        dragHeight = window.getHeight();

        JRootPane rootPane = LuckWindowUtil.getRootPane(window);

        if(rootPane != null && LuckWindowUtil.isResizable(window))
        {
            dragCursor = getCursor(dragWidth, dragHeight, e.getPoint(), rootPane.getInsets());
        }
    }
}
 
源代码20 项目: rapidminer-studio   文件: WindowChoreographer.java
/**
 * Check if there is enough space for the Window
 *
 * @param w
 *            The window to insert
 * @param yOffset
 *            The start offset of the Window
 * @return true if it fits on the screen
 */
private boolean fitsScreen(Window w, int yOffset) {
	return yOffset + w.getHeight() <= parent.getHeight() && parent.getWidth() >= w.getWidth() + DEFAULT_RIGHT_MARGIN;
}