public class NewHierarchy extends ExistingHierarchy
Isolates a ComponentHierarchy to limit to only those components created during the lifetime of this
hierarchy. Existing AWT or Swing Components (and any subsequently generated sub-windows) are ignored by
default.
Implicitly auto-filters Windows which are disposed (i.e. generates a WindowEvent#WINDOW_CLOSED
event), but also implicitly un-filters them if they should be shown again. Any Window explicitly disposed by
the calling ComponentHierarchy.dispose(java.awt.Window) will be ignored permanently.
| Modifier and Type | Method and Description |
|---|---|
Collection<Component> |
childrenOf(Component c)
Returns all the children of the given AWT or Swing
Component, omitting those which are currently filtered. |
boolean |
contains(Component c)
Returns
true if the given AWT or Swing Component is not ignored. |
void |
dispose(Window w)
Disposes the given
Window, but only if it currently exists within the hierarchy. |
void |
ignoreExisting()
Makes all currently existing AWT and Swing
Component invisible to this hierarchy, without affecting their
current state. |
static NewHierarchy |
ignoreExistingComponents()
Creates a new
NewHierarchy which does not contain any existing AWT or Swing Components. |
static NewHierarchy |
includeExistingComponents()
Creates a new
NewHierarchy which contains existing AWT or Swing Components. |
void |
recognize(Component c)
Make the given AWT or Swing
Component visible to this hierarchy. |
Collection<Container> |
roots() |
parentOf@Nonnull public static NewHierarchy ignoreExistingComponents()
NewHierarchy which does not contain any existing AWT or Swing Components.@Nonnull public static NewHierarchy includeExistingComponents()
NewHierarchy which contains existing AWT or Swing Components.@RunsInCurrentThread public void ignoreExisting()
Makes all currently existing AWT and Swing Component invisible to this hierarchy, without affecting their
current state.
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.
@RunsInCurrentThread public void recognize(@Nonnull Component c)
Make the given AWT or Swing Component visible to this hierarchy.
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.
c - the given Component.@RunsInCurrentThread @Nonnull public Collection<Component> childrenOf(@Nonnull Component c)
Returns all the children of the given AWT or Swing Component, omitting those which are currently filtered.
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.
childrenOf in interface ComponentHierarchychildrenOf in class ExistingHierarchyc - the given Component.Component, omitting those which are currently filtered.@RunsInCurrentThread public boolean contains(@Nonnull Component c)
Returns true if the given AWT or Swing Component is not ignored.
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.
contains in interface ComponentHierarchycontains in class ExistingHierarchyc - the given Component.true if the given Component is not ignored, false otherwise.@RunsInCurrentThread public void dispose(@Nonnull Window w)
Disposes the given Window, but only if it currently exists within the hierarchy. It will no longer appear
in this hierarchy or be reachable in a hierarchy walk.
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.
dispose in interface ComponentHierarchydispose in class ExistingHierarchyw - the Window to dispose.@Nonnull public Collection<Container> roots()
roots in interface ComponentHierarchyroots in class ExistingHierarchyCopyright © 2014 AssertJ. All rights reserved.