1. Member
Join Date
Jul 2010
Posts
27
Rep Power
0

## Simple Graphics

Hello guys, I am learning how to make ovals, rectangles, and all of the simple applet stuff right now. But I have some problems to understand how the coordinates work while trying to use all those figures to make drawings like a pumpkin, train etc.(Which i have the code but don't understand them). So my question is how the coordinates work and how can I draw the figure (in paper o I have heard people said that they used photoshop) before I write the code so that i can know in which coordinate and weight, height to make the drawing look nice?

2. Best way I think is to find or write a simple program and try out various things to see how they work. Read the API doc for the Graphics and Graphics2D classes to see how their methods work. Then change your simple program to try using what you have read about.

3. Member
Join Date
Jul 2010
Posts
27
Rep Power
0
Hello Norm, I have been reading and found out how to make polygons, right now i am making a house. Which I only have the ceiling, but i have another problem. I make a triangle, and a rectangle to make the ceiling, but the polygon i used to complete the ceiling made 2 tringles instead of 1. Here is the code(I leave some space on the top to make a sun and clouds later on):

Java Code:
```import java.awt.*;
import java.applet.*;

public class GUILab extends Applet{
public void paint(Graphics g){
House casa=new House(g);
}
}
class House{
public House(Graphics g){
Tri(g);
Tech(g);
}
public void Tri(Graphics g){
Polygon tri=new Polygon();
g.setColor(Color.blue);
g.fillPolygon(tri);
}
public void Tech(Graphics g){
Polygon tech=new Polygon();
g.setColor(Color.red);
g.fillPolygon(tech);
}
}```

4. How did you put together the points that you are trying to draw? You need to take a piece of paper and write down the points in the order you want them and then transpose them into your program.

5. Member
Join Date
Jul 2010
Posts
27
Rep Power
0
That's what I did, but idk why it does that, did u run it to saw the problem?

6. Try redesigning/changing the polygon points to be the shape you want.

7. Member
Join Date
Jul 2010
Posts
27
Rep Power
0
Now it works thanks.
Java Code:
```import java.awt.*;
import java.applet.*;

public class GUILab extends Applet{
public void paint(Graphics g){
House casa=new House(g);
}
}
class House{
public House(Graphics g){
Tech(g);
Tri(g);
}
public void Tri(Graphics g){
Polygon tri=new Polygon();
g.setColor(Color.blue);
g.fillPolygon(tri);
}
public void Tech(Graphics g){
g.setColor(Color.red);
g.fillRect(200, 250, 250, 150);
}
}```

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•