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 TypeMethodDescriptionbooleanReturnstrueif the specifiedObjectis aNestedComponentsinstance and all shares all of the same field references (==) as thisNestedComponentsfor fieldsearchSrc,child, andparent.static NestedComponentsCreates and returns a newNestedComponentsinstance, searching the parentContainerhierarcy of the specifiedsearchSrcfor an ancestor of typechildClassand a more senior ancestor of typeparentClass.inthashCode()Overridden to match theequals()method.booleanisFull()Returnstrueif bothchildandparentfields are non-null;falseotherwise.
-
Field Details
-
searchSrc
-
child
-
parent
-
-
Method Details
-
find
Creates and returns a newNestedComponentsinstance, searching the parentContainerhierarcy of the specifiedsearchSrcfor an ancestor of typechildClassand a more senior ancestor of typeparentClass.If either
searchSrc,childClass, orparentClassisnull, this method returnsnull.If
searchSrcis an instanceofchildClass, then thechildfield on the resultingNestedComponentswill be equal (==) to thesearchSrcfield. IfsearchSrcis an instanceofparentClass, then theparentfield on the resultingNestedComponentswill be equal (==) to thesearchSrcfield. If an instance ofparentClassis found beforechildClass, this the resultingNestedComponentsinstance will have anullchildfield.- Parameters:
searchSrc- theComponentfrom which to start searching for parentContainers.childClass- theClassof the desired "child"ComponentparentClass- theClassof the desired "parent"Component- Returns:
- a new
NestedComponentsinstance based upon the specified parameters.
-
isFull
public boolean isFull()Returnstrueif bothchildandparentfields are non-null;falseotherwise.- Returns:
trueif bothchildandparentfields are non-null;falseotherwise.
-
hashCode
public int hashCode()Overridden to match theequals()method. -
equals
Returnstrueif the specifiedObjectis aNestedComponentsinstance and all shares all of the same field references (==) as thisNestedComponentsfor fieldsearchSrc,child, andparent.
-