JPanel fatPanel = new JPanel();
JPanel calPanel = new JPanel();
JPanel perPanel = new JPanel();
public percentFatPanel()
{
fatPanel.add( fatLabel );
fatPanel.add( inFat );
calPanel.add( calLabel );
calPanel.add( inCal );
perPanel.add( perLabel );
perPanel.add( outPer );
. . . .
}
BoxLayout Layout Manager
Now add the top label, the three panels, and the button to the content pane.
We want these to
line up in a vertical column.
FlowLayout would do this if the frame
is not too wide.
But to be certain that the panels line up,
use
BoxLayout.
This layout manager
aligns components either horizontally or vertically
within a pane.
BoxLayout(Container box, int axis)
box: the container this layout manager is for
axis: BoxLayout.X_AXIS -- for left to right alignment
BoxLayout.Y_AXIS -- for top to bottom alignment
box is a reference to the container
which will be
managed by this layout manager.
Often the container is a content pane.
Set the layout manager for out application. Make the layout top to bottom.
(Fill the text fields using copy and paste from the above paragraphs.)