Calling on methods and fields in containing class

I want to add a 'close' button to a tab contained within a JTabbedPane and can't.

My situation is this: I have an overall GUI class, which deals with the overall program and always runs. This contains a JTabbedPane, which in turn contains a bunch of JPanels. Each JPanel is its own class and has its own code because they do funky stuff.

I want to add a 'close' button to the JPanels so that they can close themselves, but I can't call the removeTabAt() method in the JFrame class since the JTabbedPane isn't static (if I make it static it stops working). How on earth do I get these tabs to remove themselves?

[636 byte] By [chris_uk_83a] at [2007-11-27 11:12:26]
# 1

JFrame? Close panels?

If you want to remove a tab from the tabbed pane, wouldn'T oyu just need to get the tab's parent?

CeciNEstPasUnProgrammeura at 2007-7-29 13:54:38 > top of Java-index,Java Essentials,Java Programming...
# 2

Yes, but I can't get hold of the tab's parent because it's in another class. Unless there's a method that a JPanel can call to shut itself down. I've looked for this but I can't find it.

chris_uk_83a at 2007-7-29 13:54:38 > top of Java-index,Java Essentials,Java Programming...
# 3

java.awt.Component.getParent()?

CeciNEstPasUnProgrammeura at 2007-7-29 13:54:38 > top of Java-index,Java Essentials,Java Programming...
# 4

Cheers, that's brilliant. I've fixed it now. Thanks a lot.

chris_uk_83a at 2007-7-29 13:54:38 > top of Java-index,Java Essentials,Java Programming...