com.abstractics.utils.swing
Class SwingUtils

java.lang.Object
  extended bycom.abstractics.utils.swing.SwingUtils

public final class SwingUtils
extends java.lang.Object

Various static method utilities for dealing with Swing related tasks.

Version:
$Id: SwingUtils.java,v 1.3 2006/03/15 05:37:30 andyman99 Exp $
Author:
Andrew Lawrence, Copyright 2006 Abstractics, L.L.C., Licensed under the Apache License, Version 2.0

Method Summary
static void applyKeyListenerToEverything(java.awt.Component component, java.awt.event.KeyListener l)
          Given a component and a key listener to apply, this method applies the listener to the component and to all of its decendant children if it is a java.awt.Container object.
static void centerWindowToScreen(java.awt.Window window)
          Given a Window object, this method will set it's top/left corner so that the window is centered to the screen using its preferred size.
static int convertStringAlign(java.lang.String str, int defaultAlign)
          Converts String alignments (left, right, north, middle, etc.) into SwingConstants compass alignment values (NORTH, SOUTH, CENTER, etc.)
static java.awt.Component getChildNamed(java.lang.String name, java.awt.Container container)
          Recursively searches through the contained components of the container parameter until a child with the name specified is found.
static java.util.List getChildOfType(java.lang.Class clazz, java.awt.Container container)
          Recursively searches through the contained components of the container parameter and returns a List of components that are instances of the class given.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getChildNamed

public static java.awt.Component getChildNamed(java.lang.String name,
                                               java.awt.Container container)
Recursively searches through the contained components of the container parameter until a child with the name specified is found. Returns null if not found.

Parameters:
name -
container -
Returns:

convertStringAlign

public static int convertStringAlign(java.lang.String str,
                                     int defaultAlign)
Converts String alignments (left, right, north, middle, etc.) into SwingConstants compass alignment values (NORTH, SOUTH, CENTER, etc.)

Parameters:
str - String to convert
defaultAlign - The default alignment value to return if conversion is not possible
Returns:
SwingConstants compass alignment value

getChildOfType

public static java.util.List getChildOfType(java.lang.Class clazz,
                                            java.awt.Container container)
Recursively searches through the contained components of the container parameter and returns a List of components that are instances of the class given.

Parameters:
clazz - The Class type to search for
container - The top level container to search in
Returns:
List of components found. Might be empty, but will not be null

centerWindowToScreen

public static void centerWindowToScreen(java.awt.Window window)
Given a Window object, this method will set it's top/left corner so that the window is centered to the screen using its preferred size. If the window is larger than the screen, then the top/left corner is set to (0,0), but no resizing is done.

Parameters:
window - Window object to center

applyKeyListenerToEverything

public static void applyKeyListenerToEverything(java.awt.Component component,
                                                java.awt.event.KeyListener l)
Given a component and a key listener to apply, this method applies the listener to the component and to all of its decendant children if it is a java.awt.Container object.

Parameters:
component -
l -