public class UIUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
UIUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Frame |
getFrameAncestor(Component c)
Get the top level fra,e that contains the given component.
|
static Frame |
getSharedFrame() |
static Image |
getStockImage(String id,
Class clazz)
Get a stock image
|
static Window |
getWindowAncestor(Component c)
Get the top level window that contains the given component.
|
static void |
gridBagAdd(Container parent,
Component componentToAdd,
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 Image |
loadImage(Class clazz,
String resource)
Load an image using the specified
Classes
ClassLoader and the given resource name. |
static void |
positionComponent(int p,
Component c)
Position a component on the screen (must be a
java.awt.Window to be useful) |
static void |
setCodeBase(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(String id,
String resource)
Set an alternative stock image resource.
|
static Image |
waitFor(Image image,
Component component)
Wait for an image to load.
|
public static final int CENTER
public static final int NORTH
public static final int NORTH_EAST
public static final int EAST
public static final int SOUTH_EAST
public static final int SOUTH
public static final int SOUTH_WEST
public static final int WEST
public static final int NORTH_WEST
public static Image waitFor(Image image, Component component)
image - image to wait forcomponent - image producer componentnull if the image did not loadpublic static void setCodeBase(URL codebase)
codebase - applet codebasepublic static Image loadImage(Class clazz, String resource)
Classes
ClassLoader and the given resource name. null
will be returned if the image could not be loaded.clazz - class to get class loader fromresource - resource namepublic static void gridBagAdd(Container parent, Component componentToAdd, GridBagConstraints constraints, int pos)
GridBagLayout
, together with its constraints and the
GridBagConstraints.gridwidth value.parent - parent containercomponentToAdd - component to addconstraints - contraintspos - grid width positionIllegalArgumentExceptionpublic static Window getWindowAncestor(Component c)
c - componentpublic static Frame getFrameAncestor(Component c)
c - componentpublic static void positionComponent(int p,
Component c)
java.awt.Window to be useful)p - postion from SwingConstantsc - componentpublic static Frame getSharedFrame()
public static Image getStockImage(String id, Class clazz)
id - stock image id. See StockIcons for
constants.clazz - the Class to derive a ClassLoader from to load
the image with.public static void setStockImage(String id, String resource)
null
resource will remove any custom resource and rever to the default.id - stock image id. See StockIcons for
constants.resource - the resource path to use to load the image.Copyright © 2021. All rights reserved.