Create the logo as shown in Java in an applet or frame. It should be as close as
ID: 3695726 • Letter: C
Question
Create the logo as shown in Java in an applet or frame. It should be as close as possible, including the Virus Logo. Draw the logo using ovals, lines, rectangles, and strings, changing colors and using draw or fill as necessary. Change to appropriate virus colors (like Blue and Cyan) and fonts for the text in the drawing. Everything should be drawn in paint() with your Graphics object. After creating one virus, usecopyArea() to copy the virus bugs to other areas of the Container.
Document your .java file with five lines at the top and five lines throughout explaining the purpose of the program. Take a picture of your output with <Alt><Ptr>, paste into Paint, and save as a .jpg. Submit both your .java program and .jpg files. Please post the image of the output as well .
Explanation / Answer
import java.awt.*; public class Animate extends javax.swing.JApplet implements Runnable { Image[] picture = new Image[6]; int totalPictures = 0; int current = 0; Thread runner; int pause = 500; public void init() { for (int i = 0; i < 6; i++) { String imageText = null; imageText = getParameter("image"+i); if (imageText != null) { totalPictures++; picture[i] = getImage(getCodeBase(), imageText); } else break; } String pauseText = null; pauseText = getParameter("pause"); if (pauseText != null) { pause = Integer.parseInt(pauseText); } } public void paint(Graphics screen) { super.paint(screen); Graphics2D screen2D = (Graphics2D) screen; if (picture[current] != null) screen2D.drawImage(picture[current], 0, 0, this); } public void start() { if (runner == null) { runner = new Thread(this); runner.start(); } } public void run() { Thread thisThread = Thread.currentThread(); while (runner == thisThread) { repaint(); current++; if (current >= totalPictures) current = 0; try { Thread.sleep(pause); } catch (InterruptedException e) { } } } public void stop() { if (runner != null) { runner = null; } } }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.