Sunday, November 2, 2008

lecture 4

1. What do you understand by the term event driven programming? In particular explain what events are and how they are handled by the event handling mechanism in Java.

Event driven programming is a technique where the program "listens out" to actions made by the user to determine the sequence it will perform its methods . It then awaits further response from the use

In Java events could mean selecting a radio button or menu item, manipulating a scroll bar or clicking a button.

2. Assume that there are several buttons in a frame. Each button when clicked generates an event. In this case do we need to have a unique listener for each button? What is the benefit of the approach that you have chosen.

If there are several buttons in a frame,you can create an anonymous inner class for each button which is one-to-one mapping.the benefit of this is that it does not slow down the run-time.

No comments: