Swing Component Hierarchy and Overhead

Hi folks,

I'll try to present this as visually as I can, and then ask my question since the relevant code is long and spread across multiple classes/packages:

Say you have a component hierarchy like this:

JFrame

/\

/ \

JPanelJToolBar

/ \

/ \

JListJButton

And the JButton pops up a JFileChooser which returns a list of files, and you want to display the files in the JList, is there a lot of overhead associated with

creating a mutator in the JButton's class that "sets" the parent JFrame in the JButton?

For example:

private JFrame parent;

publicvoid setTopParent(JFrame parent)

{

this.parent = parent;

}

in order to gain access to the JFrame's children in a different branch of the component tree? Is there a best way to do this?

Thanks,

Joe

Message was edited by:

Joe_h

Edit: I had the component tree spaced so that it looks like a tree, but apparently Jive collapses all the whitespace.

Message was edited by:

Joe_h

[1239 byte] By [Joe_ha] at [2007-11-27 7:45:25]
# 1
You can use the SwingUtilities.windowForComponent(...) method.
camickra at 2007-7-12 19:26:07 > top of Java-index,Desktop,Core GUI APIs...
# 2
Oh my god. I had no idea about the whole SwingUtilities set. You've just saved me like a gajillion hours.THANKS!JoeMessage was edited by: Joe_h
Joe_ha at 2007-7-12 19:26:07 > top of Java-index,Desktop,Core GUI APIs...