com.sshtools.ui.awt
Class UIUtil

java.lang.Object
  extended by com.sshtools.ui.awt.UIUtil

public class UIUtil
extends java.lang.Object

Useful UI utilies for AWT.

Author:
$Author: brett $

Field Summary
static int CENTER
          The central position in an area.
static int EAST
          Compass-direction east (right).
static int NORTH
          Compass-direction North (up).
static int NORTH_EAST
          Compass-direction north-east (upper right).
static int NORTH_WEST
          Compass-direction north west (upper left).
static int SOUTH
          Compass-direction south (down).
static int SOUTH_EAST
          Compass-direction south-east (lower right).
static int SOUTH_WEST
          Compass-direction south-west (lower left).
static int WEST
          Compass-direction west (left).
 
Constructor Summary
UIUtil()
           
 
Method Summary
static java.awt.Frame getFrameAncestor(java.awt.Component c)
          Get the top level fra,e that contains the given component.
static java.awt.Frame getSharedFrame()
           
static java.awt.Image getStockImage(java.lang.String id, java.lang.Class clazz)
          Get a stock image
static java.awt.Window getWindowAncestor(java.awt.Component c)
          Get the top level window that contains the given component.
static void gridBagAdd(java.awt.Container parent, java.awt.Component componentToAdd, java.awt.GridBagConstraints constraints, int pos)
          Add a component to a container that is using a GridBagLayout, together with its constraints and the GridBagConstraints.gridwidth value.
static java.awt.Image loadImage(java.lang.Class clazz, java.lang.String resource)
          Load an image using the specified Classes ClassLoader and the given resource name.
static void positionComponent(int p, java.awt.Component c)
          Position a component on the screen (must be a java.awt.Window to be useful)
static void setCodeBase(java.net.URL codebase)
          If images are to be loaded in an applet, the this method should be called during the applets initialisation so they can be located.
static void setStockImage(java.lang.String id, java.lang.String resource)
          Set an alternative stock image resource.
static java.awt.Image waitFor(java.awt.Image image, java.awt.Component component)
          Wait for an image to load.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER
The central position in an area. Used for both compass-direction constants (NORTH, etc.) and box-orientation constants (TOP, etc.).

See Also:
Constant Field Values

NORTH

public static final int NORTH
Compass-direction North (up).

See Also:
Constant Field Values

NORTH_EAST

public static final int NORTH_EAST
Compass-direction north-east (upper right).

See Also:
Constant Field Values

EAST

public static final int EAST
Compass-direction east (right).

See Also:
Constant Field Values

SOUTH_EAST

public static final int SOUTH_EAST
Compass-direction south-east (lower right).

See Also:
Constant Field Values

SOUTH

public static final int SOUTH
Compass-direction south (down).

See Also:
Constant Field Values

SOUTH_WEST

public static final int SOUTH_WEST
Compass-direction south-west (lower left).

See Also:
Constant Field Values

WEST

public static final int WEST
Compass-direction west (left).

See Also:
Constant Field Values

NORTH_WEST

public static final int NORTH_WEST
Compass-direction north west (upper left).

See Also:
Constant Field Values
Constructor Detail

UIUtil

public UIUtil()
Method Detail

waitFor

public static java.awt.Image waitFor(java.awt.Image image,
                                     java.awt.Component component)
Wait for an image to load.

Parameters:
image - image to wait for
component - image producer component
Returns:
image or null if the image did not load

setCodeBase

public static void setCodeBase(java.net.URL codebase)
If images are to be loaded in an applet, the this method should be called during the applets initialisation so they can be located.

Parameters:
codebase - applet codebase

loadImage

public static java.awt.Image loadImage(java.lang.Class clazz,
                                       java.lang.String resource)
Load an image using the specified Classes ClassLoader and the given resource name. null will be returned if the image could not be loaded.

Parameters:
clazz - class to get class loader from
resource - resource name

gridBagAdd

public static void gridBagAdd(java.awt.Container parent,
                              java.awt.Component componentToAdd,
                              java.awt.GridBagConstraints constraints,
                              int pos)
Add a component to a container that is using a GridBagLayout, together with its constraints and the GridBagConstraints.gridwidth value.

Parameters:
parent - parent container
componentToAdd - component to add
constraints - contraints
pos - grid width position
Throws:
java.lang.IllegalArgumentException

getWindowAncestor

public static java.awt.Window getWindowAncestor(java.awt.Component c)
Get the top level window that contains the given component.

Parameters:
c - component
Returns:
window

getFrameAncestor

public static java.awt.Frame getFrameAncestor(java.awt.Component c)
Get the top level fra,e that contains the given component.

Parameters:
c - component
Returns:
frame

positionComponent

public static void positionComponent(int p,
                                     java.awt.Component c)
Position a component on the screen (must be a java.awt.Window to be useful)

Parameters:
p - postion from SwingConstants
c - component

getSharedFrame

public static java.awt.Frame getSharedFrame()
Returns:

getStockImage

public static java.awt.Image getStockImage(java.lang.String id,
                                           java.lang.Class clazz)
Get a stock image

Parameters:
id - stock image id. See StockIcons for constants.
clazz - the Class to derive a ClassLoader from to load the image with.

setStockImage

public static void setStockImage(java.lang.String id,
                                 java.lang.String resource)
Set an alternative stock image resource. Setting a null resource will remove any custom resource and rever to the default.

Parameters:
id - stock image id. See StockIcons for constants.
resource - the resource path to use to load the image.


Copyright © 2003-2004 3SP LTD. All Rights Reserved.