The trick, as always, is to use another panel.
The left and right panels are put in yet
another panel (called dataPan
in the program.
The buttons are put in butPan
Now dataPan
and butPan
are
added to the content pane using BoxLayout
and vertical alignment.
The picture shows how this works.
This idea of nesting panels is a powerful one. It may look complicated and tedious, but it is much less so than laying out a design on graph paper and absolutely specifying the size and location of all the components. Such a design has no flexibility. What happens if you want to add or delete a component? Everything must change. With Java's layout managers everything is dynamically adjusted.