TAILIEUCHUNG - Java Programming for absolute beginner- P19

Java Programming for absolute beginner- P19:Hello and welcome to Java Programming for the Absolute Beginner. You probably already have a good understanding of how to use your computer. These days it’s hard to find someone who doesn’t, given the importance of computers in today’s world. Learning to control your computer intimately is what will separate you from the pack! By reading this book, you learn how to accomplish just that through the magic of programming. | 2 25 03 8 55 AM Page 318 Java Programming for the Absolute Beginner and then fill a rectangle of the same size over it in a different color you would still see the right and bottom edges of the drawn rectangle because it is one pixel wider and taller. For example 10 10 100 100 10 10 100 100 Using this code in the paint Graphics method you would see a green rectangle with a black right and bottom edge. This same idea holds true for all draw and fill methods of the Graphics class. Try it out and see for yourself. FIGURE Drawing rectangles is the coolest. 10 10 10 200 250 10 300 250 Here is the source code for an application that illustrates these methods RectTest Demonstrates drawing Rectangles import . public class RectTest extends Canvas public RectTest super setSize 300 200 setBackground public static void main String args RectTest rt new RectTest GUIFrame frame new GUIFrame Rectangle Test rt team Line - live informative Nan-cast and Genuine Please purchase PDF Split-Merge on to remove this watermark. 2 25 03 8 55 AM Page 319 true public void paint Graphics g 10 10 150 150 250 10 200 150 10 200 250 150 100 100 300 250 100 100 50 75 This application renders four rectangles as shown in Figure . The first one upper-left is drawn at point 10 10 and is 150 wide by 150 high. The second rectangle upper-right is filled with the color blue at position 250 10 with dimensions 200 by 150. The next rectangle lower-left is rounded drawn at position 10 200 with a width of 250 and a height of 150. An arc of a circular diameter of 100 rounds the corners. The fourth and final rectangle lower-right is a round rectangle filled at position 300 250 with a dimension