Description:
To start the applet ,click the button on the applet, named "Front
Net". On the frame click the blue button once to set the ball location,
and by using the scrollbars set the location of the target. Once again
click the blue button and the ball goes to the target.
The program name is Penalty.java. The jdk1.1 version is used. The penalty
applet is used at the beginning with its components: one is the button;
named Front Net; and the other images. By clicking the Button we are opening
the frame, which contains a Canvas class and other awt components.
In the frame we used Scrollbar components, buttons for closing the
frame and shooting the ball and replacing it again.
To replace the ball user click the blue button on the frame once
and once again to kick the ball.
For the moment the goalkeeper is not attemt to catch the ball but for
future we are planning so.
The important methods and the classes used in the
program are:
public void init(); intially set the applet layout and
the images used at the applet.
public void paint (Graphics g); once the init is used paint
method draws the images.
class ButtonHandler implements ActionListener; once the button
is cilcked on the applet, it opens the frame.
class NetWindow extends Frame implements ActionListener; implements
the methods to draw the frame, like the buttons to quit the frame and to
kick the ball, scrollbars for target setting, and the other images.
public void setParent(Penalty a ) ; this method sets the ball
location and kale(net) images.
NetWindow(String title), this is the first instance of its class
to construct the object.
private void add(Component c, GridBagLayout gbl, GridBagConstraints
gbc, int x, int y, int w, int h); in the frame GridBagLayout
is used which is the most flexible one for future concerns.
public void actionPerformed( ActionEvent e); this method
is used accordingly when the buttons are used at the frame.
class ScrollbarHandlerX implements AdjustmentListener ; sets
the horizontal lcation of the target.
class ScrollbarHandlerY implements AdjustmentListener ; sets
the vertical location of the target.
class DrawCanvas extends Canvas; draw the images and other things
on the frame
public void setBallX( int x)
public void setBallY( int y);these methods of Canvas set
the position of the ball initially.
public void start( ), this is used to start the ball settings.
public void ballgone, after the kick it starts a new ball class.
public void shoot( ), make the kicking action by specifying
the speed and size reduction of the ball.
class Ball implements Runnable , treats the ball as a Thread
and make use of the thread properties of the ball to run it separately.
Object Model