Đang chuẩn bị liên kết để tải về tài liệu:
Java Programming for absolute beginner- P19

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

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. | JavaProgAbsBeg-09.qxd 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 g.setColor Color.black g.drawRect 10 10 100 100 g.setColor Color.green g.fillRect 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 9.3 Drawing rectangles is the coolest. 10 10 10 200 250 10 300 250 Here is the source code for RectTest.java an application that illustrates these methods RectTest Demonstrates drawing Rectangles import java.awt. public class RectTest extends Canvas public RectTest super setSize 300 200 setBackground Color.white public static void main String args RectTest rt new RectTest GUIFrame frame new GUIFrame Rectangle Test frame.add rt team Line - live informative Nan-cast and Genuine Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. JavaProgAbsBeg-09.qxd 2 25 03 8 55 AM Page 319 frame.pack frame.setVisible true public void paint Graphics g g.drawRect 10 10 150 150 g.setColor Color.blue g.fillRect 250 10 200 150 g.setColor Color.red g.drawRoundRect 10 200 250 150 100 100 g.setColor Color.green g.fillRoundRect 300 250 100 100 50 75 This application renders four rectangles as shown in Figure 9.3. 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

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.