Building the Backward Button
File:
BackwardButton.java
Contents
Overview
Like its sibling, the ForwardButton class, BackwardButton is a subclass of RolloverButton. It specifies a series of images that represent the appearance of a backward or previous control.
The image on the right shows the various images used by this button. This class implements a single method, initImages( ) which is declared as abstract in RolloverButton.
Steps to Follow
This class does not import any packages. It uses only the default package java.lang.* and classes in its default package. This class is derived from RolloverButton which we
examined earlier.
public class BackwardButton extends RolloverButton
{
protected void initImages( )
{
|
//Initialize images for the BackwardButton
//Insert "BackwardButton initImages"
|
We have only a single method that was defined as an abstract method in RolloverButton. This method specifies the images to be used for this button. Locate the BackwardButton initImages clipping in the BackwardButton folder and drag it directly
below the last line of code shown above. Your code should now look like this:
public class BackwardButton extends RolloverButton
{
protected void initImages( )
{
//Initialize images for the BackwardButton
//Insert "BackwardButton initImages"
|
addImage("images/RWW.jpg", upImage);
addImage("images/RWWa.jpg", downImage);
addImage("images/RWWb.jpg", rolloverImage);
|
}
}
|
This method looks nearly identical to the implementation of the ForwardButton. Thats because we are doing basically the same thing. The only difference is that we are specifying a different set of images.
Back to top
This class is very similar to ForwardButton.java. Due to our architecture,
this class is fairly trivial. The next (and final) step in our series
of button classes is to implement the PlayPauseButton.
To return to main tutorial file, click here.
|