net.infonode.gui
Class ComponentUtil

java.lang.Object
  extended by net.infonode.gui.ComponentUtil

public class ComponentUtil
extends java.lang.Object


Constructor Summary
private ComponentUtil()
           
 
Method Summary
static int countComponents(java.awt.Container c)
           
static java.awt.Component findComponentUnderGlassPaneAt(java.awt.Point p, java.awt.Component top)
           
static java.awt.Component findFirstComponentOfType(java.awt.Component comp, java.lang.Class c)
           
static java.awt.Color getBackgroundColor(java.awt.Component component)
           
static java.lang.String getBorderLayoutOrientation(Direction d)
           
static java.awt.Component getChildAt(java.awt.Container container, java.awt.Point p)
           
static java.awt.Component getChildAtLine(java.awt.Container container, java.awt.Point p, boolean horizontal)
           
static int getComponentIndex(java.awt.Component component)
           
static void getComponentTreePosition(java.awt.Component c, java.util.ArrayList pos)
           
static int getPreferredMaxHeight(java.awt.Component[] components)
          Calculates preferred max height for the given components without checking isVisible.
static int getPreferredMaxWidth(java.awt.Component[] components)
          Calculates preferred max width for the given components without checking isVisible.
static java.awt.Component getTopLevelAncestor(java.awt.Component c)
           
static java.awt.Component getVisibleChildAt(java.awt.Container container, java.awt.Point p)
           
static int getVisibleChildrenCount(java.awt.Component c)
           
static boolean hasVisibleChildren(java.awt.Component c)
           
static boolean isFocusable(java.awt.Component c)
           
static boolean isOnlyVisibleComponent(java.awt.Component c)
           
static boolean isOnlyVisibleComponents(java.awt.Component[] c)
           
static boolean requestFocus(java.awt.Component component)
          Requests focus unless the component already has focus.
static void setAllOpaque(java.awt.Container c, boolean opaque)
           
static java.awt.Component smartRequestFocus(java.awt.Component component)
          Requests focus for a component.
static void validate(java.awt.Component c)
           
static void validate(javax.swing.JComponent c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentUtil

private ComponentUtil()
Method Detail

getChildAt

public static final java.awt.Component getChildAt(java.awt.Container container,
                                                  java.awt.Point p)

getVisibleChildAt

public static final java.awt.Component getVisibleChildAt(java.awt.Container container,
                                                         java.awt.Point p)

getChildAtLine

public static final java.awt.Component getChildAtLine(java.awt.Container container,
                                                      java.awt.Point p,
                                                      boolean horizontal)

getComponentTreePosition

public static void getComponentTreePosition(java.awt.Component c,
                                            java.util.ArrayList pos)

findComponentUnderGlassPaneAt

public static java.awt.Component findComponentUnderGlassPaneAt(java.awt.Point p,
                                                               java.awt.Component top)

getComponentIndex

public static final int getComponentIndex(java.awt.Component component)

getBorderLayoutOrientation

public static final java.lang.String getBorderLayoutOrientation(Direction d)

getBackgroundColor

public static java.awt.Color getBackgroundColor(java.awt.Component component)

countComponents

public static int countComponents(java.awt.Container c)

getVisibleChildrenCount

public static int getVisibleChildrenCount(java.awt.Component c)

getTopLevelAncestor

public static java.awt.Component getTopLevelAncestor(java.awt.Component c)

hasVisibleChildren

public static boolean hasVisibleChildren(java.awt.Component c)

isOnlyVisibleComponent

public static boolean isOnlyVisibleComponent(java.awt.Component c)

isOnlyVisibleComponents

public static boolean isOnlyVisibleComponents(java.awt.Component[] c)

findFirstComponentOfType

public static java.awt.Component findFirstComponentOfType(java.awt.Component comp,
                                                          java.lang.Class c)

isFocusable

public static boolean isFocusable(java.awt.Component c)

requestFocus

public static boolean requestFocus(java.awt.Component component)
Requests focus unless the component already has focus. For some weird reason calling Component.requestFocusInWindow()when the component is focus owner changes focus owner to another component!

Parameters:
component - the component to request focus for
Returns:
true if the component has focus or probably will get focus, otherwise false

smartRequestFocus

public static java.awt.Component smartRequestFocus(java.awt.Component component)
Requests focus for a component. If that's not possible it's FocusTraversalPolicyis checked. If that doesn't work all it's children is recursively checked with this method.

Parameters:
component - the component to request focus for
Returns:
the component which has focus or probably will obtain focus, null if no component will receive focus

getPreferredMaxHeight

public static int getPreferredMaxHeight(java.awt.Component[] components)
Calculates preferred max height for the given components without checking isVisible.

Parameters:
components - Components to check
Returns:
max height

getPreferredMaxWidth

public static int getPreferredMaxWidth(java.awt.Component[] components)
Calculates preferred max width for the given components without checking isVisible.

Parameters:
components - Components to check
Returns:
max width

setAllOpaque

public static void setAllOpaque(java.awt.Container c,
                                boolean opaque)

validate

public static void validate(javax.swing.JComponent c)

validate

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