Class NestedComponents
- java.lang.Object
-
- org.flexdock.util.NestedComponents
-
public class NestedComponents extends java.lang.ObjectThis is a utility class for small, short-lived object instances used to find nestedComponents. It models a relationship between nestedComponentswithin an AWTContainerhierarchy such that, given a startingComponentfrom which to search, it will find twoComponentsnested within each other of specific class types. The "deeper" component will be a descendent of the "parent" component.For example, given a
JTextFieldwithin 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 allJTablesembedded withinJSplitPanesare significant within the particular application. Thefind(Component searchSrc, Class childClass, Class parentClass)method on this class will be able to return aNestedComponentsinstance indicating whether the specified text field resides within aJTablethat is embedded within aJSplitPane.Although perhaps a bit contrived, this example shows a generic use for this class. The FlexDock framework itself has a particular interest in
Dockablecomponents that are embedded withinDockingPorts, especially during drag operations. As aDockableis dragged over anDockingPort, this class allows the framework to determine with a single object instance anyDockablescurrently embedded within the targetDockingPort, starting with the deepestComponentat the current mouse point during the drag.This classes' member fields are
publicand 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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Returnstrueif the specifiedObjectis aNestedComponentsinstance and all shares all of the same field references (==) as thisNestedComponentsfor fieldsearchSrc,child, andparent.static NestedComponentsfind(java.awt.Component searchSrc, java.lang.Class childClass, java.lang.Class parentClass)Creates 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.
-
-
-
Method Detail
-
find
public static NestedComponents find(java.awt.Component searchSrc, java.lang.Class childClass, java.lang.Class parentClass)
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.- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hash code value for this object.
- See Also:
equals(Object)
-
equals
public boolean equals(java.lang.Object obj)
Returnstrueif the specifiedObjectis aNestedComponentsinstance and all shares all of the same field references (==) as thisNestedComponentsfor fieldsearchSrc,child, andparent.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- theObjectto test for equality- Returns:
trueif the specifiedObjectis "equal" to thisNestedComponentsinstance;falseotherwise.
-
-