org.assertj.swing.hierarchy
Class ExistingHierarchy

java.lang.Object
  extended by org.assertj.swing.hierarchy.ExistingHierarchy
All Implemented Interfaces:
ComponentHierarchy
Direct Known Subclasses:
NewHierarchy

public class ExistingHierarchy
extends Object
implements ComponentHierarchy

Provides access to the current AWT hierarchy.

Author:
Alex Ruiz, Yvonne Wang

Constructor Summary
ExistingHierarchy()
           
 
Method Summary
 Collection<Component> childrenOf(Component c)
           Returns all descendants of interest of the given AWT or Swing Component.
 boolean contains(Component c)
          Returns whether the given AWT or Swing Component is reachable from any of the root windows.
 void dispose(Window w)
           Properly disposes of the given Window, making it and its native resources available for garbage collection.
 Container parentOf(Component c)
           Returns the parent for the given AWT or Swing Component.
 Collection<Container> roots()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExistingHierarchy

public ExistingHierarchy()
Method Detail

roots

@Nonnull
public Collection<Container> roots()
Specified by:
roots in interface ComponentHierarchy
Returns:
all root Containers in the ComponentHierarchy.

parentOf

@RunsInCurrentThread
public Container parentOf(@Nonnull
                                              Component c)

Returns the parent for the given AWT or Swing Component.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.

Specified by:
parentOf in interface ComponentHierarchy
Parameters:
c - the given Component.
Returns:
the parent for the given Component.

contains

public boolean contains(@Nonnull
                        Component c)
Returns whether the given AWT or Swing Component is reachable from any of the root windows. The default is to consider all components to be contained in the hierarchy, whether they are reachable or not.

Specified by:
contains in interface ComponentHierarchy
Parameters:
c - the given Component.
Returns:
true.

childrenOf

@RunsInCurrentThread
@Nonnull
public Collection<Component> childrenOf(@Nonnull
                                                                    Component c)

Returns all descendants of interest of the given AWT or Swing Component.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.

Specified by:
childrenOf in interface ComponentHierarchy
Parameters:
c - the given Component.
Returns:
all descendants of interest of the given Component.

dispose

@RunsInCurrentThread
public void dispose(@Nonnull
                                        Window w)

Properly disposes of the given Window, making it and its native resources available for garbage collection.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.

Specified by:
dispose in interface ComponentHierarchy
Parameters:
w - the Window to dispose.


Copyright © 2014–2015 AssertJ. All rights reserved.