import javax.swing.JPanel; import java.awt.Graphics; import javax.swing.ImageIcon; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; /** * CS1322: Programming Assignment # - Spring 2003 - Phase * *
* Class SideBar.java- * * Revisions: 1.0 Apr. 17, 2003 * Created the SideBar class * ** * Collaboration statement: * "I worked on the homework assignment alone, using only course materials." * * @author Chris Wells * @version Version 1.0, Apr. 17, 2003 */ public class SideBar extends JPanel { /** * The path of the picture to paint. */ private String picPath; /** * Creates a new
SideBar
panel.
*/
public SideBar(GridBagLayout gridBag, GridBagConstraints c,String picPath
) {
this.picPath = picPath;
gridBag.setConstraints(this, c);
}
/**
* Overwrites the paintComponent
to paint the sidebar image.
*/
protected void paintComponent(Graphics g) {
ImageIcon sideBarPic = new ImageIcon(picPath);
g.drawImage(sideBarPic.getImage(),0,0,this.getWidth(),
this.getHeight(), this);
}
}// end of class SideBar