net.infonode.gui

Class ComponentUtil

public class ComponentUtil extends Object

Method Summary
static intcountComponents(Container c)
static ComponentfindComponentUnderGlassPaneAt(Point p, Component top)
static ComponentfindFirstComponentOfType(Component comp, Class c)
static ColorgetBackgroundColor(Component component)
static StringgetBorderLayoutOrientation(Direction d)
static ComponentgetChildAt(Container container, Point p)
static ComponentgetChildAtLine(Container container, Point p, boolean horizontal)
static intgetComponentIndex(Component component)
static voidgetComponentTreePosition(Component c, ArrayList pos)
static intgetPreferredMaxHeight(Component[] components)
Calculates preferred max height for the given components without checking isVisible.
static intgetPreferredMaxWidth(Component[] components)
Calculates preferred max width for the given components without checking isVisible.
static ComponentgetTopLevelAncestor(Component c)
static ComponentgetVisibleChildAt(Container container, Point p)
static intgetVisibleChildrenCount(Component c)
static booleanhasVisibleChildren(Component c)
static booleanisFocusable(Component c)
static booleanisOnlyVisibleComponent(Component c)
static booleanisOnlyVisibleComponents(Component[] c)
static booleanrequestFocus(Component component)
Requests focus unless the component already has focus.
static voidsetAllOpaque(Container c, boolean opaque)
static ComponentsmartRequestFocus(Component component)
Requests focus for a component.
static voidvalidate(JComponent c)
static voidvalidate(Component c)

Method Detail

countComponents

public static int countComponents(Container c)

findComponentUnderGlassPaneAt

public static Component findComponentUnderGlassPaneAt(Point p, Component top)

findFirstComponentOfType

public static Component findFirstComponentOfType(Component comp, Class c)

getBackgroundColor

public static Color getBackgroundColor(Component component)

getBorderLayoutOrientation

public static final String getBorderLayoutOrientation(Direction d)

getChildAt

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

getChildAtLine

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

getComponentIndex

public static final int getComponentIndex(Component component)

getComponentTreePosition

public static void getComponentTreePosition(Component c, ArrayList pos)

getPreferredMaxHeight

public static int getPreferredMaxHeight(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(Component[] components)
Calculates preferred max width for the given components without checking isVisible.

Parameters: components Components to check

Returns: max width

getTopLevelAncestor

public static Component getTopLevelAncestor(Component c)

getVisibleChildAt

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

getVisibleChildrenCount

public static int getVisibleChildrenCount(Component c)

hasVisibleChildren

public static boolean hasVisibleChildren(Component c)

isFocusable

public static boolean isFocusable(Component c)

isOnlyVisibleComponent

public static boolean isOnlyVisibleComponent(Component c)

isOnlyVisibleComponents

public static boolean isOnlyVisibleComponents(Component[] c)

requestFocus

public static boolean requestFocus(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

setAllOpaque

public static void setAllOpaque(Container c, boolean opaque)

smartRequestFocus

public static Component smartRequestFocus(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

validate

public static void validate(JComponent c)

validate

public static void validate(Component c)