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


Java Window.setBounds方法代码示例

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


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

示例1: centreOnScreen

import java.awt.Window; //导入方法依赖的package包/类
public static void centreOnScreen(Window window)
{
	Window owner = window.getOwner();

	// If the window has an owner, use the same graphics configuration so it
	// will
	// open on the same screen. Otherwise, grab the mouse pointer and work
	// from there.
	GraphicsConfiguration gc = owner != null ? owner.getGraphicsConfiguration() : MouseInfo.getPointerInfo()
		.getDevice().getDefaultConfiguration();

	if( gc != null )
	{
		window.setBounds(centre(getUsableScreenBounds(gc), window.getBounds()));
	}
	else
	{
		// Fall-back to letting Java do the work
		window.setLocationRelativeTo(null);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:ComponentHelper.java

示例2: 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

示例3: createDragWindow

import java.awt.Window; //导入方法依赖的package包/类
private Window createDragWindow( Image dragImage, Rectangle bounds ) {
    Window w = new Window( SwingUtilities.windowForComponent(sourceRow) );
    w.add(new JLabel(new ImageIcon(dragImage)));
    w.setBounds(bounds);
    w.setVisible(true);
    NativeWindowSystem nws = NativeWindowSystem.getDefault();
    if( nws.isUndecoratedWindowAlphaSupported() ) {
        nws.setWindowAlpha(w, 0.7f);
    }
    return w;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:DnDSupport.java

示例4: mouseDragged

import java.awt.Window; //导入方法依赖的package包/类
public void mouseDragged(MouseEvent e) {
    check(e);
    Window w = SwingUtilities.getWindowAncestor((Component)e.getSource());

    if (Cursor.DEFAULT_CURSOR == cursorType) {
        // resize only when mouse pointer in resize areas
        return;
    }

    Rectangle newBounds = computeNewBounds(w, getScreenLoc(e));
    if (!w.getBounds().equals(newBounds)) {
        w.setBounds(newBounds);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:DecorationUtils.java

示例5: 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

示例6: setDisplayMode

import java.awt.Window; //导入方法依赖的package包/类
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
        throw new IllegalArgumentException("Invalid display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    Window w = getFullScreenWindow();
    if (w != null) {
        WWindowPeer peer = (WWindowPeer)w.getPeer();
        configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
            dm.getBitDepth(), dm.getRefreshRate());
        // resize the fullscreen window to the dimensions of the new
        // display mode
        Rectangle screenBounds = getDefaultConfiguration().getBounds();
        w.setBounds(screenBounds.x, screenBounds.y,
                    dm.getWidth(), dm.getHeight());
        // Note: no call to replaceSurfaceData is required here since
        // replacement will be caused by an upcoming display change event
    } else {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:Win32GraphicsDevice.java

示例7: test

import java.awt.Window; //导入方法依赖的package包/类
private static void test(final Window window) throws Exception {
    final long start = System.nanoTime();
    final long end = start + NANOSECONDS.convert(1, MINUTES);

    final Runnable r1 = () -> {
        while (System.nanoTime() < end) {
            window.setBounds(window.getBounds());
        }
    };
    final Runnable r2 = () -> {
        while (System.nanoTime() < end) {
            window.getGraphicsConfiguration();
            window.getOpacity();
        }
    };

    final Thread t1 = new Thread(r1);
    final Thread t2 = new Thread(r1);
    final Thread t3 = new Thread(r2);
    final Thread t4 = new Thread(r2);

    t1.start();
    t2.start();
    t3.start();
    t4.start();
    t1.join();
    t2.join();
    t3.join();
    t4.join();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:TreeLockDeadlock.java

示例8: main

import java.awt.Window; //导入方法依赖的package包/类
public static void main(String[] args) {

        Window window = new Window(null);
        window.setSize(100, 100);
        window.setLocationByPlatform(true);

        if (!window.isLocationByPlatform()) {
            throw new RuntimeException("Location by platform is not set");
        }

        window.setLocation(10, 10);

        if (window.isLocationByPlatform()) {
            throw new RuntimeException("Location by platform is not cleared");
        }

        window.setLocationByPlatform(true);
        window.setBounds(20, 20, 50, 50);

        if (window.isLocationByPlatform()) {
            throw new RuntimeException("Location by platform is not cleared");
        }

        window.setLocationByPlatform(true);
        window.setVisible(false);

        if (window.isLocationByPlatform()) {
            throw new RuntimeException("Location by platform is not cleared");
        }

        window.setLocationByPlatform(true);
        window.setVisible(true);

        if (window.isLocationByPlatform()) {
            throw new RuntimeException("Location by platform is not cleared");
        }

        window.dispose();
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:40,代码来源:LocationByPlatformTest.java

示例9: setDisplayMode

import java.awt.Window; //导入方法依赖的package包/类
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
        throw new IllegalArgumentException("Invalid display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    Window w = getFullScreenWindow();
    if (w != null) {
        WWindowPeer peer = AWTAccessor.getComponentAccessor().getPeer(w);
        configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
            dm.getBitDepth(), dm.getRefreshRate());
        // resize the fullscreen window to the dimensions of the new
        // display mode
        Rectangle screenBounds = getDefaultConfiguration().getBounds();
        w.setBounds(screenBounds.x, screenBounds.y,
                    dm.getWidth(), dm.getHeight());
        // Note: no call to replaceSurfaceData is required here since
        // replacement will be caused by an upcoming display change event
    } else {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:Win32GraphicsDevice.java

示例10: setDisplayMode

import java.awt.Window; //导入方法依赖的package包/类
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    Window w = getFullScreenWindow();
    if (w == null) {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    if (dm == null ||
        (dm = getMatchingDisplayMode(dm)) == null)
    {
        throw new IllegalArgumentException("Invalid display mode");
    }

    if (!shutdownHookRegistered) {
        // register a shutdown hook so that we return to the
        // original DisplayMode when the VM exits (if the application
        // is already in the original DisplayMode at that time, this
        // hook will have no effect)
        shutdownHookRegistered = true;
        PrivilegedAction<Void> a = () -> {
            ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
            Runnable r = () -> {
                Window old = getFullScreenWindow();
                if (old != null) {
                    exitFullScreenExclusive(old);
                    setDisplayMode(origDisplayMode);
                }
            };
            Thread t = new Thread(rootTG, r,"Display-Change-Shutdown-Thread-"+screen);
            t.setContextClassLoader(null);
            Runtime.getRuntime().addShutdownHook(t);
            return null;
        };
        AccessController.doPrivileged(a);
    }

    // switch to the new DisplayMode
    configDisplayMode(screen,
                      dm.getWidth(), dm.getHeight(),
                      dm.getRefreshRate());

    // update bounds of the fullscreen window
    w.setBounds(0, 0, dm.getWidth(), dm.getHeight());

    // configDisplayMode() is synchronous, so the display change will be
    // complete by the time we get here (and it is therefore safe to call
    // displayChanged() now)
    ((X11GraphicsEnvironment)
     GraphicsEnvironment.getLocalGraphicsEnvironment()).displayChanged();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:58,代码来源:X11GraphicsDevice.java

示例11: setDisplayMode

import java.awt.Window; //导入方法依赖的package包/类
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    Window w = getFullScreenWindow();
    if (w == null) {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    if (dm == null ||
        (dm = getMatchingDisplayMode(dm)) == null)
    {
        throw new IllegalArgumentException("Invalid display mode");
    }

    if (!shutdownHookRegistered) {
        // register a shutdown hook so that we return to the
        // original DisplayMode when the VM exits (if the application
        // is already in the original DisplayMode at that time, this
        // hook will have no effect)
        shutdownHookRegistered = true;
        PrivilegedAction<Void> a = () -> {
            ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
            Runnable r = () -> {
                Window old = getFullScreenWindow();
                if (old != null) {
                    exitFullScreenExclusive(old);
                    if (isDisplayChangeSupported()) {
                        setDisplayMode(origDisplayMode);
                    }
                }
            };
            Thread t = new Thread(rootTG, r,"Display-Change-Shutdown-Thread-"+screen);
            t.setContextClassLoader(null);
            Runtime.getRuntime().addShutdownHook(t);
            return null;
        };
        AccessController.doPrivileged(a);
    }

    // switch to the new DisplayMode
    configDisplayMode(screen,
                      dm.getWidth(), dm.getHeight(),
                      dm.getRefreshRate());

    // update bounds of the fullscreen window
    w.setBounds(0, 0, dm.getWidth(), dm.getHeight());

    // configDisplayMode() is synchronous, so the display change will be
    // complete by the time we get here (and it is therefore safe to call
    // displayChanged() now)
    ((X11GraphicsEnvironment)
     GraphicsEnvironment.getLocalGraphicsEnvironment()).displayChanged();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:60,代码来源:X11GraphicsDevice.java

示例12: setDisplayMode

import java.awt.Window; //导入方法依赖的package包/类
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    Window w = getFullScreenWindow();
    if (w == null) {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    if (dm == null ||
        (dm = getMatchingDisplayMode(dm)) == null)
    {
        throw new IllegalArgumentException("Invalid display mode");
    }

    if (!shutdownHookRegistered) {
        // register a shutdown hook so that we return to the
        // original DisplayMode when the VM exits (if the application
        // is already in the original DisplayMode at that time, this
        // hook will have no effect)
        shutdownHookRegistered = true;
        PrivilegedAction<Void> a = () -> {
            Runnable r = () -> {
                Window old = getFullScreenWindow();
                if (old != null) {
                    exitFullScreenExclusive(old);
                    if (isDisplayChangeSupported()) {
                        setDisplayMode(origDisplayMode);
                    }
                }
            };
            String name = "Display-Change-Shutdown-Thread-" + screen;
            Thread t = new Thread(
                  ThreadGroupUtils.getRootThreadGroup(), r, name, 0, false);
            t.setContextClassLoader(null);
            Runtime.getRuntime().addShutdownHook(t);
            return null;
        };
        AccessController.doPrivileged(a);
    }

    // switch to the new DisplayMode
    configDisplayMode(screen,
                      dm.getWidth(), dm.getHeight(),
                      dm.getRefreshRate());

    // update bounds of the fullscreen window
    w.setBounds(0, 0, dm.getWidth(), dm.getHeight());

    // configDisplayMode() is synchronous, so the display change will be
    // complete by the time we get here (and it is therefore safe to call
    // displayChanged() now)
    ((X11GraphicsEnvironment)
     GraphicsEnvironment.getLocalGraphicsEnvironment()).displayChanged();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:61,代码来源:X11GraphicsDevice.java


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