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?
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?
Edit:
Here is what it would look like. If the panel is big enough, show two columns. Otherwise show one column.
2 Columns:
Some Key _______________ Key 2 ________________
Another Key _______________ Yet Another Key ________________
Key 5 _______________ Key 6 ________________
1 Column
Some Key _______________
Key 2 _______________
Another Key _______________
Yet Another Key _______________
Key 5 _______________
Key 6 ________________