edu.northwestern.at.utils.swing
Class WindowPositioning

java.lang.Object
  extended by edu.northwestern.at.utils.swing.WindowPositioning

public class WindowPositioning
extends java.lang.Object

Utilities for positioning Swing windows.


Method Summary
static void centerWindowOverWindow(java.awt.Window window1, java.awt.Window window2, int offset)
          Centers one window over another window.
static void staggerWindowOverWindow(java.awt.Window window1, java.awt.Window window2, int offset)
          Staggers one window over another window.
static boolean tooBig(javax.swing.JFrame window)
          Returns true if a window is too big for an 800 by 600 screen.
static void trim(javax.swing.JFrame window)
          Trims a window's size so it fits in the main screen, if necessary.
static void zoom(java.awt.Window window, java.awt.Dimension d)
          Zooms a window to fill the main screen or to a max size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

centerWindowOverWindow

public static void centerWindowOverWindow(java.awt.Window window1,
                                          java.awt.Window window2,
                                          int offset)
Centers one window over another window.

This method is typically called after the window to be centered has been packed, but before it is shown.

Parameters:
window1 - The window to be centered.
window2 - The window over which window1 is to be centered. If this window is null, window1 is centered over the screen.
offset - The vertical offset. Window1 is centered over window2 horizontally and positioned this many pixels below the top of window2.

staggerWindowOverWindow

public static void staggerWindowOverWindow(java.awt.Window window1,
                                           java.awt.Window window2,
                                           int offset)
Staggers one window over another window.

This method is typically called after the window to be staggered has been packed, but before it is shown.

Parameters:
window1 - The window to be staggered.
window2 - The window over which window1 is to be staggered. If this window is null, window1 is positioned at the top left of the screen.
offset - The offset. Window1 is staggered over window2 and positioned this many pixels below the top of window2 and to the right of window2.

zoom

public static void zoom(java.awt.Window window,
                        java.awt.Dimension d)
Zooms a window to fill the main screen or to a max size.

Parameters:
window - The window.
d - The maximum window dimension.

trim

public static void trim(javax.swing.JFrame window)
Trims a window's size so it fits in the main screen, if necessary.

The window's content pane must be a JComponent.

This method should be called before packing the window.

Parameters:
window - The window.

tooBig

public static boolean tooBig(javax.swing.JFrame window)
Returns true if a window is too big for an 800 by 600 screen.

Parameters:
window - The window.
Returns:
True if too big.