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 Component
s (and any subsequently generated sub-windows) are ignored by
default.
Implicitly auto-filters Window
s 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 Component s. |
static NewHierarchy |
includeExistingComponents()
Creates a new
NewHierarchy which contains existing AWT or Swing Component s. |
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 Component
s.@Nonnull public static NewHierarchy includeExistingComponents()
NewHierarchy
which contains existing AWT or Swing Component
s.@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 ComponentHierarchy
childrenOf
in class ExistingHierarchy
c
- 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 ComponentHierarchy
contains
in class ExistingHierarchy
c
- 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 ComponentHierarchy
dispose
in class ExistingHierarchy
w
- the Window
to dispose.@Nonnull public Collection<Container> roots()
roots
in interface ComponentHierarchy
roots
in class ExistingHierarchy
Copyright © 2014–2019 AssertJ. All rights reserved.