A good answer might be:

Notice that some Panels contain only one component.

Adding Panels to the Frame

Now the Panels must be added to the Frame. Here is the part of the program that does that:

public class percentFat extends Frame implements ActionListener
{
  . . . . . . .

  Panel ttlPanel   = new Panel();   // title 
  Panel fatPanel   = new Panel();   // fat input components
  Panel calPanel   = new Panel();   // calorie input components
  Panel perPanel   = new Panel();   // percent fat output components
  Panel butPanel   = new Panel();   // do it button
  . . . . . . .
      
  percentFat()            // constructor
  {  
    setTitle("Calories from Fat");
    setLayout( new GridLayout(5, 1) );       // choose the layout manager 

    ttlPanel.add( title );
    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( ) ;
. . . . . . . } . . . . . . . }

Remember that with GridLayout the components must be added in raster order.

QUESTION 14:

When adding these Panels, why can we say just "add" without using dot notation (as was needed in the previous group of statements)?

Click Here after you have answered the question