Page 690 - Introduction to Programming with Java: A Problem Solving Approach
P. 690
656 Chapter 16 GUI Programming Basics
//**********************************************************
// Inner class for event handling.
1. listener class heading
private class Listener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
}
String message; // the personalized greeting
message = "Glad to meet you, " + nameBox.getText()+ "!";
nameBox.setText("");
greeting.setText(message);
// end actionPerformed
2. event handler
}
// end class Greeting
Apago PDF Enhancer
} // end class Listener
//**********************************************************
public static void main(String[] args)
{
new Greeting();
} // end main
After pressing Enter in the text box:
Figure 16.5b Greeting program—part B, and its associated output