Question: /* An applet shell Anderson, Franceschi */ import java.awt.Color; import java.awt.Graphics; import java.awt.Polygon; import javax.swing.JApplet; public class ShellApplet extends JApplet { public void paint(Graphics g)
/* An applet shell Anderson, Franceschi */
import java.awt.Color; import java.awt.Graphics; import java.awt.Polygon; import javax.swing.JApplet;
public class ShellApplet extends JApplet {
public void paint(Graphics g) { super.paint(g);
// Student code starts here:
// Student code ends here. }
}
Programming Activity 4-1 Guidance ================================= Required items -------------- As stated in the textbook activity, your drawing must include at least: 2 rectangles 2 ovals 2 circle 2 lines 1 polygon 3 colors (with one being a custom color) 1 text label Required positioning technique ------------------------------ You must use relative positioning. Declare and initialize starting x and y coordinates. Use offsets from these values to code all figure positions. The last video on relative positioning takes this a step further. It shows you how to have more than one base point, if you want. Running the applet ------------------ You will run your applet in the JDK applet viewer, not in a web browser. To run an applet in TextPad: Make sure your applet file is the current tab. Use Tools > External Tools > Run Java Applet To run an applet in NetBeans: Make sure your applet file is the current tab. Use Run > File Control the layout ------------------ Use a html page with an applet tag to define your applet's window size. You can make your applet window whatever dimensions you decide. You do this via the HTML page's width and height attribute values. Make sure your starting x and y coordinates, combined with your shape offsets, do not cause parts of your drawing to disappear beyond the viewing area. Window size ----------- The maximum x and y values depend on the width and height attribute values set in the applet tag in the html page. Coordinate system ----------------- In a traditional math coordinate system, y values increase as you move up. In the Java graphics coordinate system: The origin is in the upper left corner of the viewing window. y values increase as you move down. Negative coordinates are off the visible screen area to the left or above. Other applet methods -------------------- You do not need to include the init(), start(), stop(), and destroy() applet functions. You only need to have a paint method as shown in the book and the videos.
Programming Activity 4-1
Complete Chapter 4, Programming Activity 1: Writing an Applet with Graphics.
See "Example Programming Activity 4-1 Output" in this week's "Activity resources". This example draws a train. Your applet must draw something other than a train.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
