A good answer might be:

setTitle( "Calories from Fat" )

Complete Application

Here is the complete application, suitable for copying to an editor, saving to a file, and running.

import java.awt.* ;
import java.awt.event.*;
import javax.swing.*;
   
public class percentFat extends JFrame implements ActionListener
{
  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!");
    
  int calories ;  // input: total calories per serving
  int fatGrams ;  // input: grams of fat per serving
  double percent; // result: percent of calories from fat
    
  public percentFat()   
  {  
    setTitle( "Calories from Fat" );
    getContentPane().setLayout( new FlowLayout() );
   
    getContentPane().add( title );  
    getContentPane().add( fatLabel );  
    getContentPane().add( inFat );    
    getContentPane().add( calLabel );  
    getContentPane().add( inCal );    
    getContentPane().add( perLabel );   
    getContentPane().add( outPer );   
    outPer.setEditable( false );    
   
    getContentPane().add( doit );     
    doit.addActionListener( this );
  }
   
  // The application
  public void calcPercent( )  
  {
    percent = ( (fatGrams * 9.0) / calories ) * 100.0 ;
  }
   
  public void actionPerformed( ActionEvent evt)  
  {
    String userIn ;
    userIn    = inFat.getText()  ;
    fatGrams  = Integer.parseInt( userIn ) ;
   
    userIn    = inCal.getText()  ;
    calories  = Integer.parseInt( userIn ) ;
   
    calcPercent() ;
   
    outPer.setText( (percent+"       ").substring(0,6) );
    repaint();                  
  }
   
  public static void main ( String[] args )
  {
    percentFat fatApp  = new percentFat() ;
   
    WindowQuitter wquit = new WindowQuitter(); 
    fatApp.addWindowListener( wquit );
    
    fatApp.setSize( 280, 200 );     
    fatApp.setVisible( true );         
  }
}
   
class  WindowQuitter  extends WindowAdapter 
{
  public void windowClosing( WindowEvent e )
  {
    System.exit( 0 );   
  }
}

QUESTION 17:

Could this program easily be changed into other GUI programs?