My Movies 1.0.0

hirondelle.movies.util.ui
Class UiUtil

Object
  extended by UiUtil

public final class UiUtil
extends Object

Static convenience methods for GUIs which eliminate code duplication.

Your application will likely need to add to such a class. For example, using GrdiBagLayout usually benefits from utility methods to reduce code repetition.


Nested Class Summary
static class UiUtil.AlignX
          Enumeration for horizontal alignment.
static class UiUtil.AlignY
          Type-safe enumeration vertical alignment.
 
Constructor Summary
UiUtil()
           
 
Method Summary
static void alignAllX(Container aContainer, UiUtil.AlignX aAlignment)
          Imposes a uniform horizontal alignment on all items in a container.
static void alignAllY(Container aContainer, UiUtil.AlignY aAlignment)
          Imposes a uniform vertical alignment on all items in a container.
static void beep()
          Make the system emit a beep.
static void centerAndShow(Window aWindow)
          pack, center, and show a window on the screen.
static void centerOnParentAndShow(Window aWindow)
          A window is packed, centered with respect to a parent, and then shown.
static ImageIcon createImageIcon(String aPath, String aDescription, Class aClass)
          Create an icon for use by a given class.
static void equalizeSizes(List<JComponent> aComponents)
          Sets the items in aComponents to the same size.
static Frame getActiveFrame()
          Return the currently active frame.
static JComponent getCommandColumn(List<JComponent> aButtons)
          Make a vertical row of buttons of equal size, whch are equally spaced, and aligned on the right.
static JComponent getCommandRow(List<JComponent> aButtons)
          Make a horizontal row of buttons of equal size, whch are equally spaced, and aligned on the right.
static String getDialogTitle(String aSpecificDialogName)
          Return text which conforms to the Look and Feel Design Guidelines for the title of a dialog : the application name, a colon, then the name of the specific dialog.
static Dimension getDimensionFromPercent(int aPercentWidth, int aPercentHeight)
          Return a Dimension whose size is defined not in terms of pixels, but in terms of a given percent of the screen's width and height.
static Border getStandardBorder()
          Return a border of dimensions recommended by the Java Look and Feel Design Guidelines, suitable for many common cases.
static void noDefaultButton(JRootPane aRootPane)
          Ensure that aRootPane has no default button associated with it.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UiUtil

public UiUtil()
Method Detail

centerAndShow

public static void centerAndShow(Window aWindow)
pack, center, and show a window on the screen.

If the size of aWindow exceeds that of the screen, then the size of aWindow is reset to the size of the screen.


centerOnParentAndShow

public static void centerOnParentAndShow(Window aWindow)
A window is packed, centered with respect to a parent, and then shown.

This method is intended for dialogs only.

If centering with respect to a parent causes any part of the dialog to be off screen, then the centering is overidden, such that all of the dialog will always appear fully on screen, but it will still appear near the parent.

Parameters:
aWindow - must have non-null result for aWindow.getParent.

getStandardBorder

public static Border getStandardBorder()
Return a border of dimensions recommended by the Java Look and Feel Design Guidelines, suitable for many common cases.

Each side of the border has size UiConsts.STANDARD_BORDER.


getDialogTitle

public static String getDialogTitle(String aSpecificDialogName)
Return text which conforms to the Look and Feel Design Guidelines for the title of a dialog : the application name, a colon, then the name of the specific dialog.

Example return value: My Movies: Login

Parameters:
aSpecificDialogName - must have visible content

getCommandRow

public static JComponent getCommandRow(List<JComponent> aButtons)
Make a horizontal row of buttons of equal size, whch are equally spaced, and aligned on the right.

The returned component has border spacing only on the top (of the size recommended by the Look and Feel Design Guidelines). All other spacing must be applied elsewhere ; usually, this will only mean that the dialog's top-level panel should use getStandardBorder().

Parameters:
aButtons - contains the buttons to be placed in a row.

getCommandColumn

public static JComponent getCommandColumn(List<JComponent> aButtons)
Make a vertical row of buttons of equal size, whch are equally spaced, and aligned on the right.

The returned component has border spacing only on the left (of the size recommended by the Look and Feel Design Guidelines). All other spacing must be applied elsewhere ; usually, this will only mean that the dialog's top-level panel should use getStandardBorder().

Parameters:
aButtons - contains the buttons to be placed in a column

getActiveFrame

public static Frame getActiveFrame()
Return the currently active frame.


getDimensionFromPercent

public static final Dimension getDimensionFromPercent(int aPercentWidth,
                                                      int aPercentHeight)
Return a Dimension whose size is defined not in terms of pixels, but in terms of a given percent of the screen's width and height.

Use to set the preferred size of a component to a certain percentage of the screen.

Parameters:
aPercentWidth - percentage width of the screen, in range 1..100.
aPercentHeight - percentage height of the screen, in range 1..100.

equalizeSizes

public static void equalizeSizes(List<JComponent> aComponents)
Sets the items in aComponents to the same size.

Sets each component's preferred and maximum sizes. The actual size is determined by the layout manager, whcih adjusts for locale-specific strings and customized fonts. (See this Sun doc for more information.)

Parameters:
aComponents - items whose sizes are to be equalized

beep

public static void beep()
Make the system emit a beep.

May not beep unless the speakers are turned on, so this cannot be guaranteed to work.


alignAllX

public static void alignAllX(Container aContainer,
                             UiUtil.AlignX aAlignment)
Imposes a uniform horizontal alignment on all items in a container.

Intended especially for BoxLayout, where all components need to share the same alignment in order for display to be reasonable. (Indeed, this method may only work for BoxLayout, since apparently it is the only layout to use setAlignmentX, setAlignmentY.)

Parameters:
aContainer - contains only JComponent objects.

alignAllY

public static void alignAllY(Container aContainer,
                             UiUtil.AlignY aAlignment)
Imposes a uniform vertical alignment on all items in a container.

Intended especially for BoxLayout, where all components need to share the same alignment in order for display to be reasonable. (Indeed, this method may only work for BoxLayout, since apparently it is the only layout to use setAlignmentX, setAlignmentY.)

Parameters:
aContainer - contains only JComponent objects.

noDefaultButton

public static void noDefaultButton(JRootPane aRootPane)
Ensure that aRootPane has no default button associated with it.

Intended mainly for dialogs where the user is confirming a delete action. In this case, an explicit Yes or No is preferred, with no default action being taken when the user hits the Enter key.


createImageIcon

public static ImageIcon createImageIcon(String aPath,
                                        String aDescription,
                                        Class aClass)
Create an icon for use by a given class. Returns null if the icon cannot be found.

Parameters:
aPath - path to the file, relative to the calling class, as in '../images/blah.png'
aDescription - description of the image
aClass - class that needs to use the image

My Movies 1.0.0

Copyright Hirondelle Systems - Generated 2008Dec30.15.53