@Test(expected = IllegalStateException.class) public void forgettingToCallInitComponentsCausesException() { GuiActionRunner.execute( new GuiTask() { @Override protected void executeInEDT() throws Throwable { MockDialog dialog = new MockDialog(TITLE); dialog.setVisible(true); } }); }
@Override public void setVisible(boolean b) { if (b && !initialized) { throw new IllegalStateException( "Sub-class did not call initComponents() before showing dialog"); } super.setVisible(b); }
AbstractSimpleDialog extends JDialog { @Override public void setVisible(boolean b) { if (b && !initialized) { throw new IllegalStateException( "Sub-class did not call initComponents() before showing dialog"); } super.setVisible(b); } }
AbstractSimpleDialog extends JDialog { @Override public void setVisible(boolean b) { if (b && !initialized) { throw new IllegalStateException( "Sub-class did not call initComponents() before showing dialog"); } super.setVisible(b); } AbstractSimpleDialog(String title);  AbstractSimpleDialog(JFrame parent, String title);  AbstractSimpleDialog(JDialog parent, String title);  AbstractSimpleDialog(JFrame parent, String title, boolean modal, boolean resizable);  AbstractSimpleDialog(JDialog parent, String title, boolean modal, boolean resizable); }
AbstractSimpleDialog extends JDialog { @Override public void setVisible(boolean b) { if (b && !initialized) { throw new IllegalStateException( "Sub-class did not call initComponents() before showing dialog"); } super.setVisible(b); } AbstractSimpleDialog(String title);  AbstractSimpleDialog(JFrame parent, String title);  AbstractSimpleDialog(JDialog parent, String title);  AbstractSimpleDialog(JFrame parent, String title, boolean modal, boolean resizable);  AbstractSimpleDialog(JDialog parent, String title, boolean modal, boolean resizable); @Override void setVisible(boolean b); abstract JPanel createControlPanel(); abstract void onOK(); void onCancel(); void closeDialog(); }
AbstractSimpleDialog extends JDialog { @Override public void setVisible(boolean b) { if (b && !initialized) { throw new IllegalStateException( "Sub-class did not call initComponents() before showing dialog"); } super.setVisible(b); } AbstractSimpleDialog(String title);  AbstractSimpleDialog(JFrame parent, String title);  AbstractSimpleDialog(JDialog parent, String title);  AbstractSimpleDialog(JFrame parent, String title, boolean modal, boolean resizable);  AbstractSimpleDialog(JDialog parent, String title, boolean modal, boolean resizable); @Override void setVisible(boolean b); abstract JPanel createControlPanel(); abstract void onOK(); void onCancel(); void closeDialog();  }