title: How would I create a responsive layout in Java Swing
body: <p>I am displaying a list of key value pairs in a swing JPanel.  The key is displayed in a JLabel and the Value is displayed in a JTextField.  There is enough room on the panel to display 1 or 2 columns of the key value pairs depending on how big the parent JFrame is.  I would like to display 2 columns of key value pairs unless the panel gets too small.  Then I want to switch to one column.  Is this possible in Swing without writing my own custom layout manager? </p>
  
  <p>Putting each key value pair on it's own panel and adding the panels to a Flow Layout would do what I want to do except that labels would not be aligned with each other and text fields would not align with each other so it would look terrible.  Is there a better way to do this?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Here is what it would look like.  If the panel is big enough, show two columns.  Otherwise show one column.</p>
  
  <p><strong>2 Columns:</strong></p>
  
  <pre><code>   Some Key _______________                Key 2 ________________ 
  Another Key _______________      Yet Another Key ________________
        Key 5 _______________                Key 6 ________________
  </code></pre>
  
  <p><strong>1 Column</strong></p>
  
  <pre><code>       Some Key _______________                
            Key 2 _______________ 
      Another Key _______________      
  Yet Another Key _______________
            Key 5 _______________                
            Key 6 ________________
  </code></pre>