![]() |
Help: Drawing a Stick Figure
Help is available for each task, or you can go straight to the solution source code.
Task 2Draw the following elements:filled rectangle 52,52,46,74 line 76,126,43,190 line 76,126,107,190 line 99,58,134,30 line 52,58,35,115 oval 26,114,12,12 oval 134,20,12,12 oval 63,27,27,25 rectangle 36,190,16,8 rectangle 99,190,16,9 string "Stick Boy" @ 55,218Draw the filled rectangle in blue via setColor(Color.blue); and draw everything else in black; see Add a method void paint(Graphics g) to your StickyBoy class by selecting the Stickyboy class in the workbench and pressing the "Create New Method or Constructor" button on the toolbar. Then add the drawing commands to this method. All of the draw commands are done using methods of java.awt.Graphics.html>Graphics such as drawLine. You must set the color of the graphics context before a draw command to set the color. If you get stuck, look at the solution and simply paste in the
drawing code for this method.
From the Workspace window, click on the "A" button. Task 4Add two StickyBoy beans to the new applet.In the Visual Composition Editor select the "Options->Add Bean..." menu item. Select StickyBoy from the list. Click on the left half of the Applet (the dotted rectangle) to place a stickyboy. Repeat to place another, or hold the Control key and drag the current StickyBoy, creating a new copy of him. Task 5Save your applet and run it! |
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |