Hello ... Please can anyone help me in solving this problem ... I want to learn how to draw in an applet three circles and one square and a Tringle(using lines). There is a qeustion that says : Intialize a 2 dimention array to the following values { {1,10,10,130,180}, {1,40,40,20,20}, {1,90,40,20,20}, {2,50,140,50,10} } { {3,60,110,90,110}, {3,75,80,90,110}, {3,75,80,60,110} } The First elemnt of each group represents the following 1- Oval 2- Rectangle 3- Line The other 4 elements represents the arguments of the method .... =================== The following codes is what i have done till now and the two dimention arrays are also their.. So Please help me in completing the code to get the draws in the applet ... ========== import java.awt.*; import javax.swing.*;

public class DrAr2 extends JApplet { JTextArea outputArea; public void init() { outputArea = new JTextArea(); Container c = getContentPane(); c.add( outputArea ); int array1[][] = { {1,10,10,130,180}, {1,40,40,20,20}, {1,90,40,20,20}, {2,50,140,50,10} }; int array2[][] = { {3,60,110,90,110}, {3,75,80,90,110}, {3,75,80,60,110} }; } } ====== The Bear

Originally posted by A.Rahman Yusuf: There is a qeustion that says : Intialize a 2 dimention array to the following values { {1,10,10,130,180}, {1,40,40,20,20}, {1,90,40,20,20}, {2,50,140,50,10} } { {3,60,110,90,110}, {3,75,80,90,110}, {3,75,80,60,110} } The First elemnt of each group represents the following 1- Oval 2- Rectangle 3- Line

This doesn't make any sense to me. How exactly are the Oval, Rectangle, and Line represented? All I see are a bunch of numbers. In order to help, you need to explain more clearly what the numbers represent. For example, a rectangle can be represented with four numbers that represent the (x, y) coordinates for the top-left and bottom-right corner. A line can be represented with the same data, but it is just drawn differently. An oval is a bit more complicated, and I don't see how the numbers given relate. Please try to explain more clearly what the numbers represent exactly. If you don't know, then you need to find out. Layne

Painting using the Graphics object is something I did when learning Java, then never used again. Of course, that's pretty much true of applets in general. OK, I don't want to help you cheat on your assignment too much, but I'll get you started. You know applets have a paint method, right? OK, the parameter to that is a java.awt.Graphics object. The Graphics object, according to the Javadocs, have a method:

You have four numbers after each "1" indicating "oval", so just "plug and chug", as my old chemistry teacher used to say. Of course, the whole thing is full of pitfalls. You have to set a color on your Graphics object first. You have to figure out how to retrieve the numbers from the array. You have to figure out how to draw lines and rectangles for yourself. That's life in the exciting world of programming. Good luck!