Display an Image -Scaled
Here is the applet: Solution//Purpose: Open an image from the same directory as the web-page // that includes this applet and display it to the screen. import java.awt.*; import java.applet.Applet; public class test7b extends Applet { Image butch; int a_Height, a_Width; public void init() { butch = getImage(getDocumentBase(), "B.jpg"); //deterine the size of the applet a_Height= this.size().height; //can use the new getSize() method a_Width= this.size().width; } //draw Scaled Image. public void paint(Graphics g) { g.drawImage(butch, 0, 0, a_Width, a_Height, this); } } |