So, I have a snippet of code that I want to use to exit my program after a JDialog is hidden. This is my code:
JTabbedPane tp = plotter.PlotAll();
JDialog dialog = new JDialog();
dialog.add(tp);
dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
dialog.setSize(1400, 600);
dialog.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);
dialog.addComponentListener(new ComponentAdapter() {
@Override
public void componentHidden() {
System.exit(0);
}
});
dialog.setVisible(true);
The tabbed pane is just a series of plots. The error I'm getting is at the @Override command - method does not override or implement a method from a supertype. Any pointers would be greatly appreciated!
Of course as soon as I posted this I figured out a better solution. Since the dialog is modal, I can just call
System.exit(0);
after setting the dialog to visible.