finding class parent information



Hi,

I am writing some code that looks at a class, and creates some
documents based on class references that it finds using the Reflection
API. I can get all of the compponets in a class, and get references to
each object so that I can query it.

These are swing components mainly I am looking at, and what I would
like to do is to group the components together in a heirachy. For
example, take the following components:

JTabbedPane myTabs
JPanel myPanel ....
JLabel myLabel ....
JButton myButton ....

myPanel.add(myButton);
myPanel.add(myLabel);
myTabs.add(myPanel);

I want to produce a report to say the following type of thing:
JLabel called myLabel belongs to parent JPanel called myPanel
JButton called myButton belongs to parent JPanel called myPanel
JPanel called myPanel belongs to the parent JTabbedPane myTabs

I can seem to get the class type (e.g. JPanel) for a parent easilly,
and some other info, but I cant get the name for it (e.g. myPanel)

The only way I could think to get the info was using the Accessibility
methods.
In my code, I do the following to get the references to the
AccessableParent:

AccessibleContext context = myLabel.getAccessibleContext();
Accessible parent =
myLabel.getAccessibleContext().getAccessibleParent();

Then I try the following:

1) parent.getAccessibleContext().getAccessibleName()
2) parent.getClass().toString()
3) parent.toString()

And get the following output
1) = null
2) = class javax.swing.JPanel
3)
[,0,0,155x36,layout=java.awt.FlowLayout,alignmentX=null,alignmentY=null,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]

The only time I get any useful info back is if a JPanel has a titled
border - I can access the title text by calling 1) above.

I thought that something simpler may work, and tried:

Container parentCont = myLabel.getParent();
System.out.println("Parent name = "+parentCont.getName());

However, this gets null!

Any help would be appreciated.

.