go to previous page   go to home page   go to next page

Answer:

  JPanel fatPanel   = new JPanel();
  JPanel calPanel   = new JPanel();
  JPanel perPanel   = new JPanel();
  
  public percentFatPanel()   
  {  
    setTitle( "Calories from Fat" );
    outPer.setEditable( false );   
    setLayout( new FlowLayout() ); 

    hedPanel.add( heading );
    fatPanel.add( fatLabel );
    fatPanel.add( inFat );
    calPanel.add( calLabel );
    calPanel.add( inCal );
    perPanel.add( perLabel );
    perPanel.add( outPer );
    butPanel.add( doit );
    . . . .
  }

Adding Panels to the Frame

Now add the panels to the frame. This is being done in the constructor for the JFrame so add() means use the method of that frame.


  . . . . .
   
  JPanel hedPanel   = new JPanel();
  JPanel fatPanel   = new JPanel();
  JPanel calPanel   = new JPanel();
  JPanel perPanel   = new JPanel();   
  JPanel butPanel   = new JPanel();   
  
  public percentFatPanel()   
  { 
    setTitle( "Calories from Fat" );
    outPer.setEditable( false );   
    setLayout( new FlowLayout() ); 
 
    hedPanel.add( heading );
    fatPanel.add( fatLabel );
    fatPanel.add( inFat );
    calPanel.add( calLabel );
    calPanel.add( inCal );
    perPanel.add( perLabel );
    perPanel.add( outPer );
    butPanel.add( doit );
    
    add(  );
    add(  );
    add(  );
    add(  );
    add(  );
 
    . . . . . .
  }

QUESTION 6:

Add the components from top to bottom