Class NestedComponents
Components
. It models a relationship between nested
Components
within an AWT Container
hierarchy such that, given
a starting Component
from which to search, it will find two
Components
nested within each other of specific class types. The
"deeper" component will be a descendent of the "parent" component.
For example, given a JTextField
within a content frame, the
application logic may need to check to see if the text field resides within a
certain application-specific container set. Perhaps all JTables
embedded within JSplitPanes
are significant within the particular
application. The
find(Component searchSrc, Class childClass, Class parentClass)
method
on this class will be able to return a NestedComponents
instance
indicating whether the specified text field resides within a JTable
that is embedded within a JSplitPane
.
Although perhaps a bit contrived, this example shows a generic use for this
class. The FlexDock framework itself has a particular interest in
Dockable
components that are embedded within DockingPorts
,
especially during drag operations. As a Dockable
is dragged over an
DockingPort
, this class allows the framework to determine with a
single object instance any Dockables
currently embedded within the
target DockingPort
, starting with the deepest Component
at
the current mouse point during the drag.
This classes' member fields are public
and may be both accessed and
modified by external code as needed within their particular usage context.
This is by design for ease of use within the FlexDock framework.
Consequently, instances of this class should only be used for short-lived
operations. Since its member fields may be modified publicly, instances of
this class should not be cached, nor should its member values be indexed as
they are subject to arbitrary changes over the long term.
- Author:
- Christopher Butler
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if the specifiedObject
is aNestedComponents
instance and all shares all of the same field references (==) as thisNestedComponents
for fieldsearchSrc
,child
, andparent
.static NestedComponents
Creates and returns a newNestedComponents
instance, searching the parentContainer
hierarcy of the specifiedsearchSrc
for an ancestor of typechildClass
and a more senior ancestor of typeparentClass
.int
hashCode()
Overridden to match theequals()
method.boolean
isFull()
Returnstrue
if bothchild
andparent
fields are non-null
;false
otherwise.
-
Field Details
-
searchSrc
-
child
-
parent
-
-
Method Details
-
find
Creates and returns a newNestedComponents
instance, searching the parentContainer
hierarcy of the specifiedsearchSrc
for an ancestor of typechildClass
and a more senior ancestor of typeparentClass
.If either
searchSrc
,childClass
, orparentClass
isnull
, this method returnsnull
.If
searchSrc
is an instanceofchildClass
, then thechild
field on the resultingNestedComponents
will be equal (==) to thesearchSrc
field. IfsearchSrc
is an instanceofparentClass
, then theparent
field on the resultingNestedComponents
will be equal (==) to thesearchSrc
field. If an instance ofparentClass
is found beforechildClass
, this the resultingNestedComponents
instance will have anull
child
field.- Parameters:
searchSrc
- theComponent
from which to start searching for parentContainers
.childClass
- theClass
of the desired "child"Component
parentClass
- theClass
of the desired "parent"Component
- Returns:
- a new
NestedComponents
instance based upon the specified parameters.
-
isFull
public boolean isFull()Returnstrue
if bothchild
andparent
fields are non-null
;false
otherwise.- Returns:
true
if bothchild
andparent
fields are non-null
;false
otherwise.
-
hashCode
public int hashCode()Overridden to match theequals()
method. -
equals
Returnstrue
if the specifiedObject
is aNestedComponents
instance and all shares all of the same field references (==) as thisNestedComponents
for fieldsearchSrc
,child
, andparent
.
-