title: How to remove title bar in JFrame
body: <p>I'm using the following code for practising, </p>
  
  <p><a href="http://docs.oracle.com/javase/tutorial/uiswing/examples/layout/BorderLayoutDemoProject/src/layout/BorderLayoutDemo.java">http://docs.oracle.com/javase/tutorial/uiswing/examples/layout/BorderLayoutDemoProject/src/layout/BorderLayoutDemo.java</a></p>
  
  <p>I also add </p>
  
  <pre><code>frame.setSize(frame.getMaximumSize());
  </code></pre>
  
  <p>in createAndShowGUI() method,</p>
  
  <p>What is more I want this window not to have the title bar, close and minimize buttons.</p>
  
  <p>I tried the following code, </p>
  
  <pre><code>frame.setUndecorated(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  </code></pre>
  
  <p>If I added this code before the pack(), it goes into infine loop with this exception <strong>Exception in thread "AWT-EventQueue-0" java.lang.NegativeArraySizeException</strong></p>
  
  <p>If I added the last line of createAndShowGUI() method it throws <strong>Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is displayable.</strong></p>
  
  <p>What should I do ?</p>
  
  <p>Thanks.</p>