com.denova.ui
Class UiLayoutUtilities

java.lang.Object
  |
  +--com.denova.ui.UiLayoutUtilities

public class UiLayoutUtilities
extends java.lang.Object

Utilties for laying out a Swing user interface.

Author:
DeNova Copyright © 1997-2006 DeNova All rights reserved worldwide.

Field Summary
static java.lang.String CrossPlatformLookAndFeelName
           
static java.lang.String MotifLookAndFeelName
           
static java.lang.String WindowsLookAndFeelName
           
 
Constructor Summary
UiLayoutUtilities()
           
 
Method Summary
static javax.swing.JPanel addBevel(java.awt.Component c, int style)
          Thread safe way to add a beveled border to a component.
static javax.swing.JPanel addBeveledBorder(java.awt.Component c)
          Thread safe way to add a beveled border and an inside margin to a component.
static javax.swing.JPanel addBorder(java.awt.Component c, javax.swing.border.Border border)
          Thread safe way to add a border to a component.
static javax.swing.JPanel addDoubleBevel(java.awt.Component c, int style)
          Thread safe way to add a double beveled border to a component.
static javax.swing.JPanel addMargin(java.awt.Component c)
          Thread safe way to add a margin to a component.
static javax.swing.JPanel addTitledBorder(java.awt.Component c, java.lang.String title, int titlePosition)
          Thread safe way to add a titled border to a component.
static void adjustBounds(javax.swing.JFrame frame)
          Adjust the bounds of a frame so they aren't too large for the native environment or off screen.
static void centerComponent(java.awt.Component c)
          Center the component inside the parent's boundaries.
static javax.swing.JPanel centerLabel(javax.swing.JLabel l)
          Thread safe way to center a JLabel managing quirks of Swing.
static void centerOnScreen(java.awt.Container c)
          Center the container in the screen.
static javax.swing.JFrame findJFrameParent(java.awt.Container c)
          Thread safe way to find the parent of the container.
static javax.swing.JFrame forceJFrameParent(java.awt.Container c)
          Thread safe way to find the parent of the container.
static void forceRepaint(java.awt.Component c)
           
static int getDefaultMargin()
          Gets the default margin's value.
static javax.swing.border.Border getMarginBorder()
          Gets the default margin's value for a border.
static javax.swing.border.Border getMarginBorder(int margin)
          Sets an empty border with the margin surrounding it.
static java.awt.Rectangle getParentBounds(java.awt.Component c)
          Get the boundaries of the parent.
static void pack(javax.swing.JFrame frame)
           
static void paintNow(javax.swing.JComponent c)
          Thread safe way to paint the screen.
static void redraw(java.awt.Component c)
          Thread safe way to redraw the screen.
static void setBackgroundColor(java.awt.Container mainContainer, java.awt.Color backgroundColor)
          Set the background color of a component.
static void setDefaultMargin(int m)
          Sets the default margin's value.
static void setFocus(java.lang.Object field)
          Set the focus to a particular field.
static boolean setLookAndFeel()
          Sets the look and feel to the platform's native L&F.
static void unexpectedStartupError()
          Display error message that Swing is required.
static void update(java.awt.Component c, boolean value)
          Thread safe way to update Swing component.
static void update(java.awt.Component c, int value)
          Thread safe way to update Swing component.
static void update(java.awt.Component c, java.lang.Object value)
          Thread safe way to update Swing component.
static void update(java.lang.Object c, boolean value)
          Thread safe way to update Swing object.
static void update(java.lang.Object c, int value)
          Thread safe way to update Swing object.
static void update(java.lang.Object c, java.lang.Object value)
          Thread safe way to update Swing object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CrossPlatformLookAndFeelName

public static final java.lang.String CrossPlatformLookAndFeelName
See Also:
Constant Field Values

WindowsLookAndFeelName

public static final java.lang.String WindowsLookAndFeelName
See Also:
Constant Field Values

MotifLookAndFeelName

public static final java.lang.String MotifLookAndFeelName
See Also:
Constant Field Values
Constructor Detail

UiLayoutUtilities

public UiLayoutUtilities()
Method Detail

setLookAndFeel

public static boolean setLookAndFeel()
Sets the look and feel to the platform's native L&F.

Returns true if successful.


setBackgroundColor

public static void setBackgroundColor(java.awt.Container mainContainer,
                                      java.awt.Color backgroundColor)
Set the background color of a component.

c: component to change
backgroundColor: new color to use in background


update

public static void update(java.awt.Component c,
                          int value)
Thread safe way to update Swing component.

Parameters:
c - the Swing component to update
value - the new integer value to set the component to

update

public static void update(java.lang.Object c,
                          int value)
Thread safe way to update Swing object.

Parameters:
c - the Swing object to update
value - the new integer value to set the component to

update

public static void update(java.awt.Component c,
                          boolean value)
Thread safe way to update Swing component.

Parameters:
c - the Swing component to update
value - the new boolean value to set the component to

update

public static void update(java.lang.Object c,
                          boolean value)
Thread safe way to update Swing object.

Parameters:
c - the Swing object to update
value - the new boolean value to set the component to

update

public static void update(java.awt.Component c,
                          java.lang.Object value)
Thread safe way to update Swing component.

Parameters:
c - the Swing component to update
value - the new object value to set the component to

update

public static void update(java.lang.Object c,
                          java.lang.Object value)
Thread safe way to update Swing object.

Parameters:
c - the Swing object to update
value - the new object value to set the component to

adjustBounds

public static void adjustBounds(javax.swing.JFrame frame)
Adjust the bounds of a frame so they aren't too large for the native environment or off screen. Contributed by Dr Laszlo Jamf at http://forum.java.sun.com/thread.jspa?threadID=508444&messageID=2412480

Parameters:
frame - frame to adjust.

setFocus

public static void setFocus(java.lang.Object field)
Set the focus to a particular field.

You should call this after you pack() the dialog box.

Parameters:
field - the field to set the focus and cursor.

centerLabel

public static javax.swing.JPanel centerLabel(javax.swing.JLabel l)
Thread safe way to center a JLabel managing quirks of Swing.

Parameters:
l - the Swing label to center
Returns:
a JPanel with l centered in it

findJFrameParent

public static javax.swing.JFrame findJFrameParent(java.awt.Container c)
Thread safe way to find the parent of the container.

Parameters:
c - the Swing container
Returns:
the parent of the container

forceJFrameParent

public static javax.swing.JFrame forceJFrameParent(java.awt.Container c)
Thread safe way to find the parent of the container.

Creates a new JFrame if the container doesn't have a parent.

Parameters:
c - the Swing container
Returns:
the parent of the container

addBorder

public static javax.swing.JPanel addBorder(java.awt.Component c,
                                           javax.swing.border.Border border)
Thread safe way to add a border to a component.

Parameters:
c - the Swing component
border - the Swing border
Returns:
a JPanel with the component in a border

addBevel

public static javax.swing.JPanel addBevel(java.awt.Component c,
                                          int style)
Thread safe way to add a beveled border to a component.

Parameters:
c - the Swing component
style - the style of the Swing beveled border
Returns:
a JPanel with the component in a beveled border

addBeveledBorder

public static javax.swing.JPanel addBeveledBorder(java.awt.Component c)
Thread safe way to add a beveled border and an inside margin to a component.

Parameters:
c - the Swing component
Returns:
a JPanel with the component in a beveled border

addDoubleBevel

public static javax.swing.JPanel addDoubleBevel(java.awt.Component c,
                                                int style)
Thread safe way to add a double beveled border to a component.

Parameters:
c - the Swing component
style - the style of the Swing beveled border
Returns:
a JPanel with the component in a double beveled border

addTitledBorder

public static javax.swing.JPanel addTitledBorder(java.awt.Component c,
                                                 java.lang.String title,
                                                 int titlePosition)
Thread safe way to add a titled border to a component.

Parameters:
c - the Swing component
title - title
titlePosition - horizontal position of title
Returns:
a JPanel with the component in a titled border

addMargin

public static javax.swing.JPanel addMargin(java.awt.Component c)
Thread safe way to add a margin to a component.

Uses the return value from getMarginBorder() to determine the maring to add.

Parameters:
c - the Swing component
Returns:
a JPanel with the component with the additional margin

getDefaultMargin

public static int getDefaultMargin()
Gets the default margin's value.

Returns:
the default value of the margin

setDefaultMargin

public static void setDefaultMargin(int m)
Sets the default margin's value.

Parameters:
m - the new value of the default margin

getMarginBorder

public static javax.swing.border.Border getMarginBorder()
Gets the default margin's value for a border.

Returns:
the default value of the margin for a border

getMarginBorder

public static javax.swing.border.Border getMarginBorder(int margin)
Sets an empty border with the margin surrounding it.

Parameters:
margin - the margin to use when creating the border
Returns:
an empty border with the margin surrounding it

paintNow

public static void paintNow(javax.swing.JComponent c)
Thread safe way to paint the screen.

Parameters:
c - the Swing component to paint

forceRepaint

public static void forceRepaint(java.awt.Component c)

redraw

public static void redraw(java.awt.Component c)
Thread safe way to redraw the screen.

Parameters:
c - the Swing component to redraw

pack

public static void pack(javax.swing.JFrame frame)

centerOnScreen

public static void centerOnScreen(java.awt.Container c)
Center the container in the screen.

Parameters:
c - the Swing container to center

centerComponent

public static void centerComponent(java.awt.Component c)
Center the component inside the parent's boundaries.

Parameters:
c - the Swing component to center

getParentBounds

public static java.awt.Rectangle getParentBounds(java.awt.Component c)
Get the boundaries of the parent.

Parameters:
c - the Swing Component to get the parent's boundaries
Returns:
the parent's boundaries of the Component

unexpectedStartupError

public static void unexpectedStartupError()
Display error message that Swing is required.

No return value.