title: Can I set JFrame's normal size while it is maximized?
body: <p><strong>GOAL:</strong></p>
  
  <p>I'd like to have a frame visible in <code>Frame.MAXIMIZED_BOTH</code> state, but I also want it to have a predefined normal size so when the user un-maximizes it, the frame will resize to the size I want it to be. And I want the frame to first appear maximized, <strong>without a visual resize</strong>. And I want the frame to <strong>remain maximized</strong> until the user un-maximizes it.</p>
  
  <p><strong>Things that I've tried so far:</strong></p>
  
  <p><strong>1)</strong></p>
  
  <pre><code>frame.setExtendedState( Frame.MAXIMIZED_BOTH );
  frame.setVisible( true );
  frame.setSize( 500, 500 );
  </code></pre>
  
  <p><em>Evaluation:</em> The frame will switch to normal state (will not remain maximized) => not good.</p>
  
  <p><strong>2)</strong></p>
  
  <pre><code>frame.setSize( 500, 500 );
  frame.setExtendedState( Frame.MAXIMIZED_BOTH );
  frame.setVisible( true );
  </code></pre>
  
  <p><em>Evaluation:</em> The window (or just its frame) will appear with a size of 500x500, and after that a visual resize (to maximum) will be visible => not good.
  The reason for this is that if a frame is not visible, calling <code>setExtendedState()</code> will be deferred until the frame is visible.</p>
  
  <p><strong>3)</strong></p>
  
  <pre><code>frame.setSize( 500, 500 );
  frame.setVisible( true );
  frame.setExtendedState( Frame.MAXIMIZED_BOTH );
  </code></pre>
  
  <p><em>Evaluation:</em> just like in attempt #2, the frame will have a visual resize => not good.</p>
  
  <p><strong>4)</strong>
  I've tried to add a component listener to the frame overriding <code>componentResize()</code> and change state there. I've also tried adding a window state listener overriding <code>windowStateChange()</code>. I've also tried adding a window listener overriding <code>windowOpened()</code>.</p>
  
  <p><em>Evaluation:</em> All resulted in a visual resize just like in attempt #2 => not good.</p>
  
  <p>So what can I do if I want my frame to have a predefined normal size, but I want it to appear maximized?</p>
  
  <p>EDIT: edited the whole question to be more clear, and added example codes (SSCCE).</p>