title: Java GridLayout how to dynamically change grid layout
body: <p>I am trying to create a character sheet program that arranges 3 panels based on how wide the frame is. If the frame is not very wide, I want the panels to be arranged vertically, but if the user chooses to make the frame wider, I would like to arrange the panels horizontally.</p>
  
  <p>I also have a scrollPanel that the 3 panels are arranged on, so the scrollPanel is being added to a scrollPane.</p>
  
  <p>I have seen posts that say that an eventlistener would work, however most of these are for buttons, and I need the Frame size to pass a certain threshold before the layout changes. I seen other posts that recommend html which I don't see as necessary right now.</p>
  
  <p><a href="https://i.stack.imgur.com/E8ZLp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E8ZLp.png" alt="enter image description here"></a></p>
  
  <p>So in this picture the 3 panels are arranged vertically, and are able to be scrolled through.  </p>
  
  <pre><code>    scrollPanel.add(leftPanel); //this is the yellow panel that is being added
      scrollPanel.add(centerPanel); //this one is farther down
      scrollPanel.add(rightPanel); //even farther down
      scrollPanel.setBackground(Color.CYAN);
      scrollPanel.setLayout(new GridLayout(0, 1)); //so here I would like to have an if statement or event swap the 0 and the 1.
  </code></pre>
  
  <p>Summary: </p>
  
  <ul>
  <li><p>Can I change a GridLayout dynamically based on the size of a Frame?</p></li>
  <li><p>How do I monitor for a Frame size change? event? if statement?</p></li>
  <li><p>Can I do the same with a ScrollPane with setting the horizontal and vertical scroll bars to never appear based on if the panels are vertical or horizontal?</p></li>
  </ul>