Search code examples
javaswingjframejpanelswingutilities

Closing parent element of a JPanel


Is it possible to close parent element of a component .. probably a JFrame/JInternalFrame from a JPanel? if yes how it can be done?


Solution

  • This will help you:

    SwingUtilities.windowForComponent(panel).dispose();
    

    or

    SwingUtilities.windowForComponent(panel).setVisible(false);