public static void preferences() { if (pref == null) { JFrame parent = null; if (window.isVisible()) { parent = window; } PrefPanel panel; if (prefclass == null) { panel = new PrefPanel(); } else { panel = (PrefPanel) newInstance(prefclass); } panel.setParentFrame(parent); int result = JOptionPane.showConfirmDialog( parent, panel, "Preferences", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, new ImageIcon()); if (result == JOptionPane.OK_OPTION) { panel.savePreferences(); } else { } } else { pref.setVisible(true); } }