I want to close the parent frame on the click of a button in JInternalFrame
.
Parent frame as the JInternalFrame
the button is in or the JFrame
or window it is contained in?
Use either:
SwingUtilities.getWindowAncestor(button).dispose()
or
SwingUtilities.getAncestorOfClass(JInternalFrame.class, button).dispose();
or similar.
Javadoc: https://docs.oracle.com/javase/8/docs/api/javax/swing/SwingUtilities.html