title: Switching fullscreen in java and behaviour of dispose() when only having one window
body: <p>This question is about the dispose() method in java.
  I'm trying to implement a window class, in which I want to be able to switch between fullscreen exclusive mode and a normal window mode.
  According to the implementation of this <a href="http://gpsnippets.blogspot.de/2007/08/toggle-fullscreen-mode.html" rel="nofollow">this site</a> you can dispose() a frame and reuse it again. But according to the <a href="https://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#dispose%28%29" rel="nofollow">java docs</a> this could result in the VM terminating (as it is the only window I will use).</p>
  
  <p>Is the implementation according to the website simply a bad idea or am I misunderstanding something about the behaviour of dispose()?</p>
  
  <p>The code from the website:</p>
  
  <pre><code>//set the display mode back to the what it was when
  //the program was launched.
  device.setDisplayMode(dispModeOld);
  
  //hide the frame so we can change it.
  setVisible(false);
  
  //remove the frame from being displayable.
  dispose();
  
  //put the borders back on the frame.
  setUndecorated(false);
  
  //needed to unset this window as the fullscreen window.
  device.setFullScreenWindow(null);
  
  //make sure the size of the window is correct.
  setSize(800,600);
  
  //recenter window
  setLocationRelativeTo(null);
  
  //reset the display mode to what it was before
  //we changed it.
  setVisible(true);
  </code></pre>