Answer:

public class percentFatPan extends JFrame implements ActionListener
{
  public percentFatPanel()   
  {  
    getContentPane().setLayout( 
        new BoxLayout( getContentPane(), BoxLayout.Y_AXIS ); 
         
    . . . . .

Adding the Panels

Two uses of getContentPane() are needed to set the layout manager:

  1. The first getContentPane() gets the content pane whose layout manager is to be set.
  2. The second getContentPane() send a reference to the content pane to BoxLayout.

Now add the top label, the panels, and the button to the content pane:

  JLabel title      = new JLabel("Percent of Calories from Fat");
  JLabel fatLabel   = new JLabel("Enter grams of fat:   ");
  JLabel calLabel   = new JLabel("Enter total calories: ");
  JLabel perLabel   = new JLabel("Percent calories from fat: ");

  JTextField inFat  = new JTextField( 7 );
  JTextField inCal  = new JTextField( 7 );
  JTextField outPer = new JTextField( 7 );

  JButton    doit   = new JButton("Do It!");
   
  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 );
  
    getContentPane().setLayout( 
        new BoxLayout( getContentPane(), BoxLayout.Y_AXIS );  
    
    getContentPane().add( );
    getContentPane().add(  );
    getContentPane().add( );
    getContentPane().add( );
    getContentPane().add( );

QUESTION 7:

Add the components from top to bottom