fixing image size  
Author Message
andyfaeglasgow





PostPosted: 2004-3-5 0:20:00 Top

java-programmer, fixing image size I realise there have been several posting on this subject already.
However, despite these, I still can't quite work out how to do this.

I need to take the image from a file (.gif .jpg etc), ensure that the
entire image fits on a JPanel of some size, then put this JPanel onto
another Jpanel.

From what I could gather, it looked like I had to extend JPanel and
override paint(). The problem comes when I try to use drawImage().
Here's the code.

//relevent imports

public class Picture extends JPanel
{
private String fileName;

/** Creates a new instance of Picture */

public Picture(String file)
{
fileName=file;
}

public void paint(Graphics g)
{
super.paintComponent(g);

}
}