您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)


Apply Index

Apply Page # 3

Exercise 1 Event handling in Button example

Given the listing Listener1.java answer the following questions:

1. What interface does the Listener1.java implement?

2. How many AWT objects are there in this example, and what are they?

3. List the statements, which are messages to the button object.

4. When the user clicks the right hand button in the caption bar of the window will the window close?

5. How would the applet behave if the statement add(myButton); was missing?

6. What is the purpose of the keyword this ?

7. How would the applet behave is the statement myButton.addActionListener(this); was missing?

8. What would happen if the public void actionPerformed (ActionEvent e) method was missing?

9. What is the role of?the ActionEvent?object?

10. Why is the method repaint() used?


Discussion of Exercise 1 

Back to content

Back to top

basicline.gif (170 bytes)