Class ImageButton Class ImageButton java.lang.Object | +----java.awt.Component | +----java.awt.Button | +----ImageButton public class ImageButton extends Button The 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. See Also: Button ImageButton(String, AlgAnimApp, ControlPanel) Creates an ImageButton using the gif file specified by the first parameter on the panel defined by the third parameter. getPreferredSize() Specify the dimension of the button. paint(Graphics) Method to draw image on the button preferredSize() Specify the dimension of the button. print(Graphics) Method to draw image on the button setDisable() Disable the image button and set the current image to imageFileDisable.gif. setEnable() Enable the image button and set the current image to imageFile.gif update(Graphics) This method is invokes when the repaint method is called. ImageButton public ImageButton(String imageFile, AlgAnimApp app, ControlPanel parent) Creates an 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. Parameters: imageFile - The gif image file without the .gif extension. The extension will be appended when calling the Applet.getImage() method. app - An instance to an applet. The only applet in this cluster of classes, an instance of AlgAnimApp, is usually passed in here. This particular applet is used to obtain the code base, i.e. the location of the image files. parent - The panel where this image button is going to reside. This paremeter is passed in so that the repaint method for the panel can be called when a refreshing is required. getPreferredSize public Dimension getPreferredSize() Specify the dimension of the button. In this particular application, images with resolution of 42x52 are used. Therefore, this method always returns Dimension with width 42 and height 52. This method is only called by the system layout manager. Returns: The dimention of the button. Overrides: getPreferredSize in class Component preferredSize public Dimension preferredSize() Specify the dimension of the button. In this particular application, images with resolution of 42x52 are used. Therefore, this method always returns Dimension with width 42 and height 52. This method is only called by the system layout manager. Returns: The dimention of the button. Overrides: preferredSize in class Component setDisable public void setDisable() Disable the image button and set the current image to imageFileDisable.gif. setEnable public void setEnable() Enable the image button and set the current image to imageFile.gif print public void print(Graphics g) Method to draw image on the button Overrides: print in class Component update public void update(Graphics g) This method is invokes when the repaint method is called. Overrides: update in class Component paint public void paint(Graphics g) Method to draw image on the button Overrides: paint in class Component