| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Feb | ||||||
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | ||||||
Chapter 3, 3.7
1. Write the code segments that would draw the following objects in the graphics context g:
a. A filled rectangle with corner point (45,20) and size 100 by 50.
-g.drawRect(45, 20, 100,50)
b. A line segment with end points(20,20) and (100,100)
-g.drawLine(20,20,100,100)
c. A circle with center point (100,100) and radius 50.
-g.drawOval(100,100,50,50)
d. A triangle with vertices (100,100), (50,50),and (200,200)
-g.drawLine(100,100,50,50)
g.drawLine(50,50,200,200)
g.drawLine(200,200,100,100)
2. Describe the design of a program that displays a filled blue rectangle on a red background.
- public ColorPanel(Color backColor){
setBackground(Color.red)
}
g.setColor(Color.blue)
g.fillRect(10,10,50,60)
3. How does one compute the center point of a panel.
- We can use a getWidth and getHeight method to do so.
4. List the three properties of a text font.
-The three properties are name, style and size.