Snowman applet program Write a JApplet that draws a picture
Snowman applet program
Write a JApplet that draws a picture of a flower in spring. You can make it fairly crude. The Snowman applet should have everything you need. Use BlueJ for this. Extend the JApplet class as done in chapter 2. All you need to write is the paint () method. Use drawRect(), drawLine(), drawOval(), fillRect(), fillOval(), setColor() and other Java drawing tools. Don\'t worry terribly about artistic quality. This can look like a child\'s drawing. It should take about 30 statements. I\'ll put together a web gallery of your pictures and make it available on chortle. The whole world might see your art. Start the program with a documentation header that says what it is, who did it, and when. BlueJ gives you some of this automatically, but you have to fill in some things. Also, have some line-by-line documentation that says what is going on, e.g., II draw petal//draw ground//draw leaf The Java source file for your applet. Don\'t turn in the entire BlueJ project.Solution
import java.applet.Applet; import java.awt.Graphics; import java.awt.Image; public class DrawImageInApplet extends Applet { private static final long serialVersionUID = 2530894095587089544L; private Image image; // Called by the browser or applet viewer to inform // this applet that it has been loaded into the system. public void init() { image = getImage(getDocumentBase(), \"http://www.myserver.com/image.jpg\"); } // Paints the container. This forwards the paint to any // lightweight components that are children of this container. public void paint(Graphics g) { // draws as much of the specified image as is currently available g.drawImage(image, 0, 0, this); } }