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


Java Window.getHeight方法代码示例

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


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

示例1: test

import java.awt.Window; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:MouseWheelAbsXY.java

示例2: isButtonOnScreen

import java.awt.Window; //导入方法依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:33,代码来源:BubbleWindow.java

示例3: addNotify

import java.awt.Window; //导入方法依赖的package包/类
/**
 * Updates the font metrics the first time we're displayed.
 */
@Override
public void addNotify() {

	super.addNotify();

	// Some LookAndFeels (e.g. WebLaF) for some reason have a 0x0 parent
	// window initially (perhaps something to do with them fading in?),
	// which will cause an exception from getGraphics(), so we must be
	// careful here.
	if (metricsNeverRefreshed) {
		Window parent = SwingUtilities.getWindowAncestor(this);
		if (parent!=null && parent.getWidth()>0 && parent.getHeight()>0) {
			refreshFontMetrics(getGraphics2D(getGraphics()));
			metricsNeverRefreshed = false;
		}
	}

	// Re-start parsing if we were removed from one container and added
	// to another
	if (parserManager!=null) {
		parserManager.restartParsing();
	}

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:28,代码来源:RSyntaxTextArea.java

示例4: setWindowBounds

import java.awt.Window; //导入方法依赖的package包/类
final public void setWindowBounds(Window objPwindow, int intPwidth, int intPheight, Window objPparentWindow, boolean bolPrightJustified) {

		final int intLwidth = Math.min(intPwidth, Constants.intS_GRAPHICS_SCREEN_WIDTH);
		final int intLheight = Math.min(intPheight, Constants.intS_GRAPHICS_SCREEN_HEIGHT);

		final int intLparentFrameX = objPparentWindow != null ? (int) objPparentWindow.getLocation().getX() : (int) this.getLocation().getX();
		final int intLparentFrameY = objPparentWindow != null ? (int) objPparentWindow.getLocation().getY() : (int) this.getLocation().getY();
		final int intLparentFrameWidth = objPparentWindow != null	? (int) objPparentWindow.getSize().getWidth()
																	: this.getWidth() + this.getJuggleMasterPro().getFrame().getWidth();
		final int intLparentFrameHeight = objPparentWindow != null ? objPparentWindow.getHeight() : this.getHeight();

		objPwindow.setBounds(	Math.max(Constants.intS_GRAPHICS_SCREEN_X,
										Math.min(intLparentFrameX	+ (intLparentFrameWidth - intLwidth) / 2,
													(bolPrightJustified	? intLparentFrameX + intLparentFrameWidth
																		: Constants.intS_GRAPHICS_SCREEN_X + Constants.intS_GRAPHICS_SCREEN_WIDTH)
																								- intLwidth)),
								Math.max(	Constants.intS_GRAPHICS_SCREEN_Y,
											Math.min(intLparentFrameY	+ (intLparentFrameHeight - intLheight) / 2,
														Constants.intS_GRAPHICS_SCREEN_HEIGHT - intLheight)),
								intLwidth,
								intLheight);
	}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:23,代码来源:ControlJFrame.java

示例5: calculatePosition

import java.awt.Window; //导入方法依赖的package包/类
private Point calculatePosition(Component source) {
	int xSource = source.getLocationOnScreen().x;
	int ySource = source.getLocationOnScreen().y;

	// get size of popup
	Dimension popupSize = ((Component) popupComponent).getSize();
	if (popupSize.width == 0) {
		popupSize = ((Component) popupComponent).getPreferredSize();
	}

	int xPopup = 0;
	int yPopup = 0;

	// get max x and y window positions
	Window focusedWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
	int maxX = focusedWindow.getLocationOnScreen().x + focusedWindow.getWidth();
	int maxY = focusedWindow.getLocationOnScreen().y + focusedWindow.getHeight();

	switch (position) {
		case VERTICAL:

			// place popup at sources' x position
			xPopup = xSource;

			// check if popup is outside active window
			if (xPopup + popupSize.width > maxX) {

				// move popup x position to the left
				// to fit inside the active window
				xPopup = maxX - popupSize.width - BORDER_OFFSET;
			}

			// place popup always below source (to avoid overlapping)
			yPopup = ySource + source.getHeight();

			// if the popup now would be moved outside of RM Studio to the left it would look
			// silly, so in that case just show it at its intended position and let it be cut
			// off on the right side as we cannot do anything about it
			if (xPopup < focusedWindow.getLocationOnScreen().x
					|| (xPopup - focusedWindow.getLocationOnScreen().x) + popupSize.width > focusedWindow.getWidth()) {
				xPopup = xSource;
			}

			break;
		case HORIZONTAL:

			// place popup always to the right side of the source (to avoid overlapping)
			xPopup = xSource + source.getWidth();

			yPopup = ySource;

			// check if popup is outside active window
			if (yPopup + popupSize.height > maxY) {

				// move popup upwards to fit into active window
				yPopup = maxY - popupSize.height - BORDER_OFFSET;
			}

			// if the popup now would be moved outside of RM Studio at the top it would look
			// silly, so in that case just show it at its intended position and let it be cut
			// off on the bottom side as we cannot do anything about it
			if (yPopup < focusedWindow.getLocationOnScreen().y
					|| (yPopup - focusedWindow.getLocationOnScreen().y) + popupSize.height > focusedWindow.getHeight()) {
				yPopup = ySource;
			}

			break;
	}

	return new Point(xPopup, yPopup);

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:73,代码来源:PopupAction.java

示例6: mouseDragged

import java.awt.Window; //导入方法依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
	Point newPos = e.getPoint();
	SwingUtilities.convertPointToScreen(newPos, SizeGrip.this);
	int xDelta = newPos.x - origPos.x;
	int yDelta = newPos.y - origPos.y;
	Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this);
	if (wind!=null) { // Should always be true
		if (getComponentOrientation().isLeftToRight()) {
			int w = wind.getWidth();
			if (newPos.x>=wind.getX()) {
				w += xDelta;
			}
			int h = wind.getHeight();
			if (newPos.y>=wind.getY()) {
				h += yDelta;
			}
			wind.setSize(w,h);
		}
		else { // RTL
			int newW = Math.max(1, wind.getWidth()-xDelta);
			int newH = Math.max(1, wind.getHeight()+yDelta);
			wind.setBounds(newPos.x, wind.getY(), newW, newH);
		}
		// invalidate()/validate() needed pre-1.6.
		wind.invalidate();
		wind.validate();
	}
	origPos.setLocation(newPos);
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:31,代码来源:SizeGrip.java

示例7: testWindowBounds

import java.awt.Window; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:FullScreenInsets.java


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