WindowUtils Class Reference

List of all members.

Static Public Member Functions

static void centerWindow (JFrame frame)
 Plops the frame into the center of the desktop.
static void enterFullScreenIfPossible (JFrame mainAppFrame)
static void exitFullScreen (JFrame mainAppFrame)
static Point getCachedWindowOrigin (int windowWidth, int windowHeight, int where)
 Determines where to put windows based on the cached state.
static Rectangle getDesktopBounds ()
static Dimension getDesktopSize ()
static int getScreenHeight ()
static Dimension getScreenSize ()
static int getScreenWidth ()
static Point getWindowOrigin (int windowWidth, int windowHeight, int where)
 Given a size (width, height) of a window, and an intended location on the desktop, it returns the x, y location of where the origin should reside.
static Point getWindowOrigin (Frame frame, int where)
static void initCachedWindowState ()
 Call this before calling getCachedWindowOrigin(.
static void main (String[] args) throws InterruptedException
static JFrame openInJFrame (Container content, int width, int height)
 Opens a container inside a JFrame.
static JFrame openInJFrame (Container content, int width, int height, String title)
 Opens a container inside a JFrame.
static JFrame openInJFrame (Container content, int width, int height, String title, Color bgColor)
static JFrame openInJFrame (Container content, int width, int height, String title, Color bgColor, boolean exitOnClose)
 Opens a container inside a JFrame.
static void setJavaLookAndFeel ()
 The pleasant-looking *cough* Java look and feel.
static void setMotifLookAndFeel ()
 Old Skool Look and Feel.
static void setNativeLookAndFeel ()
 Windows, Mac, or Unix look and feels.
static void fitToDesktop (final JFrame frame)

Static Public Attributes

static final int DESKTOP_CENTER = 0
static final int DESKTOP_EAST = 2
static final int DESKTOP_NORTH = 3
static final int DESKTOP_NORTHEAST = 6
static final int DESKTOP_NORTHWEST = 5
static final int DESKTOP_SOUTH = 4
static final int DESKTOP_SOUTHEAST = 8
static final int DESKTOP_SOUTHWEST = 7
static final int DESKTOP_WEST = 1
static final int INVALID_MAX = 18
static final int INVALID_MIN = -1
static final int SCREEN_CENTER = 9
static final int SCREEN_EAST = 11
static final int SCREEN_NORTH = 12
static final int SCREEN_NORTHEAST = 15
static final int SCREEN_NORTHWEST = 14
static final int SCREEN_SOUTH = 13
static final int SCREEN_SOUTHEAST = 17
static final int SCREEN_SOUTHWEST = 16
static final int SCREEN_WEST = 10

Static Package Functions

 [static initializer]

Detailed Description

This class contains useful methods for positioning, sizing, and manipulating JFrames and other Window-like elements.

This software is distributed under the BSD License.

Author:
Ron B Yeh (ronyeh(AT)cs.stanford.edu)

Definition at line 25 of file WindowUtils.java.


Member Function Documentation

static void centerWindow ( JFrame  frame  )  [static]

Plops the frame into the center of the desktop.

Parameters:
frame 

Definition at line 97 of file WindowUtils.java.

References WindowUtils.getWindowOrigin().

static void enterFullScreenIfPossible ( JFrame  mainAppFrame  )  [static]

Parameters:
mainAppFrame window to be made full screen.

Definition at line 106 of file WindowUtils.java.

References WindowUtils.getScreenSize().

Referenced by WindowUtils.main().

static void exitFullScreen ( JFrame  mainAppFrame  )  [static]

Parameters:
mainAppFrame 

Definition at line 144 of file WindowUtils.java.

Referenced by WindowUtils.main().

static void fitToDesktop ( final JFrame  frame  )  [static]

Parameters:
frame Feb 16, 2006
Author:
Ron Yeh

Definition at line 466 of file WindowUtils.java.

static Point getCachedWindowOrigin ( int  windowWidth,
int  windowHeight,
int  where 
) [static]

Determines where to put windows based on the cached state.

Parameters:
windowWidth 
windowHeight 
where 
See also:
util.WindowUtilities.initCachedWindowState()

Definition at line 163 of file WindowUtils.java.

References WindowUtils.DESKTOP_CENTER, WindowUtils.DESKTOP_EAST, WindowUtils.DESKTOP_NORTH, WindowUtils.DESKTOP_NORTHEAST, WindowUtils.DESKTOP_NORTHWEST, WindowUtils.DESKTOP_SOUTH, WindowUtils.DESKTOP_SOUTHEAST, WindowUtils.DESKTOP_SOUTHWEST, WindowUtils.DESKTOP_WEST, WindowUtils.INVALID_MAX, WindowUtils.INVALID_MIN, WindowUtils.SCREEN_CENTER, WindowUtils.SCREEN_EAST, WindowUtils.SCREEN_NORTH, WindowUtils.SCREEN_NORTHEAST, WindowUtils.SCREEN_NORTHWEST, WindowUtils.SCREEN_SOUTH, WindowUtils.SCREEN_SOUTHEAST, WindowUtils.SCREEN_SOUTHWEST, and WindowUtils.SCREEN_WEST.

Referenced by WindowUtils.getWindowOrigin().

static Rectangle getDesktopBounds (  )  [static]

Returns:
the rectangle describing the user's desktop

Definition at line 272 of file WindowUtils.java.

static Dimension getDesktopSize (  )  [static]

Returns:
the size of the user's desktop

Definition at line 279 of file WindowUtils.java.

static int getScreenHeight (  )  [static]

Returns:

Definition at line 286 of file WindowUtils.java.

Referenced by WindowUtils.getScreenSize().

static Dimension getScreenSize (  )  [static]

Returns:
the screen size of the last known monitor mode

Definition at line 293 of file WindowUtils.java.

References WindowUtils.getScreenHeight(), and WindowUtils.getScreenWidth().

Referenced by WindowUtils.enterFullScreenIfPossible().

static int getScreenWidth (  )  [static]

Returns:

Definition at line 300 of file WindowUtils.java.

Referenced by WindowUtils.getScreenSize().

static Point getWindowOrigin ( Frame  frame,
int  where 
) [static]

Parameters:
frame 
where 
Returns:

Definition at line 326 of file WindowUtils.java.

References WindowUtils.getCachedWindowOrigin().

static Point getWindowOrigin ( int  windowWidth,
int  windowHeight,
int  where 
) [static]

Given a size (width, height) of a window, and an intended location on the desktop, it returns the x, y location of where the origin should reside.

This method will be pretty resilient to the user changing his/her interface (taskbar locations, etc). If you want a faster method, but would sacrifice a (little) bit of assurances... then use getCachedWindowOrigin(...) directly (after calling initCachedWindowState() once)

Parameters:
windowWidth 
windowHeight 
where 
Returns:

Definition at line 316 of file WindowUtils.java.

References WindowUtils.getCachedWindowOrigin(), and WindowUtils.initCachedWindowState().

Referenced by WindowUtils.centerWindow().

static void initCachedWindowState (  )  [static]

Call this before calling getCachedWindowOrigin(.

..) to get the current state of the user's screen and desktop size. The user may have changed it since the last call. This is called once when WindowUtils is first accessed.

Definition at line 335 of file WindowUtils.java.

Referenced by WindowUtils.getWindowOrigin().

static void main ( String[]  args  )  throws InterruptedException [static]

Parameters:
args 
Exceptions:
InterruptedException 
Author:
Ron Yeh

Definition at line 352 of file WindowUtils.java.

References WindowUtils.enterFullScreenIfPossible(), and WindowUtils.exitFullScreen().

static JFrame openInJFrame ( Container  content,
int  width,
int  height,
String  title,
Color  bgColor,
boolean  exitOnClose 
) [static]

Opens a container inside a JFrame.

Useful for quick testing.

Parameters:
content 
width 
height 
title 
bgColor 
exitOnClose 
Returns:

Definition at line 413 of file WindowUtils.java.

static JFrame openInJFrame ( Container  content,
int  width,
int  height,
String  title,
Color  bgColor 
) [static]

Parameters:
content 
width 
height 
title 
bgColor 
Returns:

Definition at line 397 of file WindowUtils.java.

References WindowUtils.openInJFrame().

static JFrame openInJFrame ( Container  content,
int  width,
int  height,
String  title 
) [static]

Opens a container inside a JFrame.

Useful for quick testing.

Parameters:
content 
width 
height 
title 
Returns:

Definition at line 385 of file WindowUtils.java.

References WindowUtils.openInJFrame().

static JFrame openInJFrame ( Container  content,
int  width,
int  height 
) [static]

Opens a container inside a JFrame.

Useful for quick testing.

Parameters:
content 
width 
height 
Returns:

Definition at line 372 of file WindowUtils.java.

Referenced by WindowUtils.openInJFrame().


The documentation for this class was generated from the following file:
Generated on Sat Apr 14 18:21:45 2007 for R3 Paper Toolkit by  doxygen 1.4.7