What method is used to get the text from the input TextField?

A good answer might be:

The TextField's getText() method.

User Input

Here is the program so far, except for a few blanks. To finish it:

  1. Use the getText() method to get the user's input.
  2. Use the parseInt() static method of the wrapper class Integer to convert the input to an int.
  3. Use the setText() method to convert and display the result in outCel.

import java.awt.*; 
import java.awt.event.*;

public class fahrConvert extends Frame implements ActionListener
{
  Label title    = new Label("Convert Fahrenheit to Celsius");
  Label inLabel  = new Label("Enter Fahrenheit");
  Label outLabel = new Label("Celsius ");

  TextField inFahr = new TextField( 7 );
  TextField outCel = new TextField( 7 );

  int fahrTemp ;
  int celsTemp ;
  
  fahrConvert()                           // constructor for fahrConvert
  {  
     setLayout( new FlowLayout() );       // choose the layout manager 

     inFahr.addActionListener( this );
     add( title );                      
     add( inLabel );                      
     add( outLabel );                      
     add( inFahr );                      
     add( outCel );                      
     outCel.setEditable( false );
  }

  public void convert( )  
  {
    celsTemp = ((fahrTemp-32) * 5) / 9;
  }

  public void actionPerformed( ActionEvent evt)  
  {
    String userIn = ______________________;
    fahrTemp = ___________________________;

    convert() ;

    ____________________( celsTemp+" " );
    repaint();                  
  }

  public static void main ( String[] args )
  {
    fahrConvert fahr  = new fahrConvert() ;
    
    WindowQuitter wquit = new WindowQuitter(); 
    fahr.addWindowListener( wquit );
    
    fahr.setSize( 200, 150 );     
    fahr.setVisible( true );      
  }

}

class  WindowQuitter  extends WindowAdapter 
{
  public void windowClosing( WindowEvent e )
  {
    System.exit( 0 );  // what to do for this event--exit the program
  }
}

QUESTION 6:

Fill in the blanks.

Click Here after you have answered the question