// Create a frame JFrame frame = new JFrame(); // Get default close operation int op = frame.getDefaultCloseOperation(); // HIDE_ON_CLOSE // Set to exit on close frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@Override public void windowClosing(WindowEvent arg0) { if (frmHtppSimulator.getDefaultCloseOperation() == JDialog.DO_NOTHING_ON_CLOSE) { JOptionPane.showMessageDialog(getJFrame(), "Before exiting you must close a test window form"); } else { // if (hostImpl != null) { // hostImpl.quit(); // } } } });
@Override public void windowClosing(WindowEvent arg0) { if (frmSmppSimulator.getDefaultCloseOperation() == JDialog.DO_NOTHING_ON_CLOSE) { JOptionPane.showMessageDialog(getJFrame(), "Before exiting you must close a test window form"); } else { // if (hostImpl != null) { // hostImpl.quit(); // } } } });
public static class UpdateTask implements ActionListener { @Override public void actionPerformed(ActionEvent ae) { Frame[] frames = Frame.getFrames(); for (Frame frame : frames) { if (frame instanceof JFrame) { JFrame change = (JFrame) frame; System.out.println("Before = " + change.getTitle() + " = " + change.getDefaultCloseOperation()); ((JFrame)frame).setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); System.out.println("After = " + change.getTitle() + " = " + change.getDefaultCloseOperation()); } } } }
private void backupProperties(JFrame frame) { oldDefaultCloseOperation = frame.getDefaultCloseOperation(); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); oldWindowListeners = frame.getWindowListeners(); for (WindowListener listener : oldWindowListeners) { frame.removeWindowListener(listener); } }
public static WindowClosingProtocol.WindowClosingMode getNWClosingOperation(final Component c) { final JFrame jf = getJFrame(c); final int op = (null != jf) ? jf.getDefaultCloseOperation() : WindowConstants.DO_NOTHING_ON_CLOSE ; return AWT2NWClosingOperation(op); } }
if (frame instanceof JFrame) { jframe = (JFrame) frame; if (jframe.getDefaultCloseOperation() == JFrame.HIDE_ON_CLOSE) jframe.setVisible(false); else if (jframe.getDefaultCloseOperation() == JFrame.DISPOSE_ON_CLOSE) jframe.dispose(); else if (jframe.getDefaultCloseOperation() == JFrame.EXIT_ON_CLOSE) System.exit(0);
initComponents(); addWindowListener(new WindowNotifier()); cboDefaultCloseOp.setSelectedIndex(getDefaultCloseOperation());
if (frame instanceof JFrame) { jframe = (JFrame) frame; if (jframe.getDefaultCloseOperation() == JFrame.HIDE_ON_CLOSE) jframe.setVisible(false); else if (jframe.getDefaultCloseOperation() == JFrame.DISPOSE_ON_CLOSE) jframe.dispose(); else if (jframe.getDefaultCloseOperation() == JFrame.EXIT_ON_CLOSE) System.exit(0);
if (frame instanceof JFrame) { jframe = (JFrame) frame; if (jframe.getDefaultCloseOperation() == JFrame.HIDE_ON_CLOSE) jframe.setVisible(false); else if (jframe.getDefaultCloseOperation() == JFrame.DISPOSE_ON_CLOSE) jframe.dispose(); else if (jframe.getDefaultCloseOperation() == JFrame.EXIT_ON_CLOSE) System.exit(0);
return ((JFrame) e.getComponent()).getDefaultCloseOperation();