java.lang.Object | +----java.awt.Component | +----java.awt.Button | +----ImageButton
ImageButton
class extends the original
java.awt.Button
to display graphical images in
gif
format. In this particular implementation,
the images to be loaded have to be located in the same
directory as the code base
(which can be accessed
using Applet.getCodeBase()
).
In order to work around the bug in some of the older java complient
web browser, in particular, the class not found
exception
during the initilization of the frame using Netscape 2.0,
this class is casted to its parent class Button
and explicitly casted back to ImageButton
when the
customized methods are required.
ImageButton
using the gif
file specified by the first parameter on the panel defined by
the third parameter.
imageFileDisable.gif
.
imageFile.gif
repaint
method
is called.
public ImageButton(String imageFile, AlgAnimApp app, ControlPanel parent)
ImageButton
using the gif
file specified by the first parameter on the panel defined by
the third parameter.
Before calling this constructor, make sure that the image file
imageFile.gif
exists. It is also required to have
another gif image imageFileDisable.gif
, which
appears to be the disabled button.
.gif
extension. The extension will be appended
when calling the Applet.getImage()
method.
AlgAnimApp
, is
usually passed in here. This particular applet is used to
obtain the code base, i.e. the location of the image files.
public Dimension getPreferredSize()
Dimension
with
width
42 and height
52.
This method is only called by the system layout manager.
public Dimension preferredSize()
Dimension
with
width
42 and height
52.
This method is only called by the system layout manager.
public void setDisable()
imageFileDisable.gif
.
public void setEnable()
imageFile.gif
public void print(Graphics g)
public void update(Graphics g)
repaint
method
is called.
public void paint(Graphics g)