Let's say I have a class which extends JPanel:
class StockScreenResultsPanel extends JPanel{
etc...
}
Then I have a handle on that class I have just retrieved it from a parent tab:
StockScreenResultsPanel childComponent = (StockScreenResultsPanel)nasdaqTab.getComponent();
I'm very sorry if this is really nooby, but I want to explicitly close childComponent (not just hide it but eliminate it from the application), and I can't find any examples.
Can someone show me how to explicitly/programmatically close a child JPanel?
I have already tried the code below and get the error "StockScreenResultsPanel cannot be converted to window"
childComponent.dispatchEvent(new WindowEvent( (Window)childComponent , WindowEvent.WINDOW_CLOSING));
Also, if I try:
childComponent.dispose()
It gives me a "cannot find symbol".
As the comments in response to my question above say, you can't close a panel, you have to use remove instead.