(a)State what is meant in Java programming by an event [2marks ]
(b)State what is meant by an event source [1mark ]
(c)State what is meant by an event handler [2marks ]
(d)Assume the following de .nition of the class MyApplet
public class MyApplet extends Applet {
private int last_x, last_y;
// Display my applet
public void paint(Grpahics g) {
g.drawString(Hello
World);
}
}
(i)Write a basic HTML file,which could be used to display this applet,with
appropriate dimensions.[4 marks ]
(ii)Add to the class MyApplet a method which will be called automatically
upon the initialisation ofthe applet,and will set the co-ordinates
ofthe points last x and last y to zero.[3 marks ]
(iii)The Applet class contains the abstract method mouseDown When
the user
clicks a mouse button,the system calls this method with a reference
to the event
object generated,and the x and y co-ordinates ofthe mouse when the
event
happened.Implement an overloading of this method in the class MyApplet
which will simply set the values of last x and last y to the values
when the
event occurs,and print out the new values.[3 marks ]
|