Use a JInternalFrame with a registered VetoableChangeListener implemented like this:
Code:
public void vetoableChange(PropertyChangeEvent pEvt) throws PropertyVetoException
{
if (JInternalFrame.IS_CLOSED_PROPERTY.equals(pEvt.getPropertyName()) && Boolean.TRUE.equals(pEvt.getNewValue()))
{
int ret = JOptionPane.showConfirmDialog(mInternalFrame, "Do you confirm ?", "confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (ret == JOptionPane.NO_OPTION)
{
throw new PropertyVetoException("", pEvt)
}
}
}