posted 20 years ago
If you don't want to keep passing around the parent frame everywhere, you can do something like this:
You put this method in Class3--or wherever you need it--and it returns the parent frame. Basically it keeps calling "getParent()" until it gets to the outermost container, which is generally a Frame (or JFrame), and returns that.
This assumes that "Class3" extends JPanel or some other UI container class where the call to "getParent()" is defined. If not, replace the first line with: Component frame = someComponent.getParent(); where "someComponent" is a UI component in the interface.
[ March 30, 2004: Message edited by: Wayne L Johnson ]