CAPITULO 12: DIBUJADO Los mecanismos de pintado de Java ...
CAPITULO 12: DIBUJADO Los mecanismos de pintado de Java ...
CAPITULO 12: DIBUJADO Los mecanismos de pintado de Java ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
15. Rectangle bounds = getBounds();<br />
16. int y = <strong>12</strong>;<br />
17. while ( y < bounds.height ) {<br />
18. g.drawString( "frame frame frame frame frame frame" ,<br />
60, y );<br />
19. y += <strong>12</strong>;<br />
20. }<br />
21. }<br />
22. }<br />
23. class RectsPanel extends Panel {<br />
24. public RectsPanel() {<br />
25. setBackground( Color.lightGray );<br />
26. }<br />
27. public void paint( Graphics g ) {<br />
28. Rectangle bounds = getBounds();<br />
29. int x = 0;<br />
30. int y = 0;<br />
31. int w = bounds.width - 1;<br />
32. int h = bounds.height - 1;<br />
33. for ( int i = 0; i < 10; i++ ) {<br />
34. g.drawRect( x, y, w, h );<br />
35. x +- 10;<br />
36. y += 10;<br />
37. w -= 20;<br />
38. h -= 20;<br />
39. }<br />
40. }<br />
41. }<br />
42. class OvalsCanvas extends Canvas {<br />
43. public OvalsCanvas() {<br />
44. setForeground( Color.white ) ;<br />
45. setBackground( Color.darkGray );<br />
46. }<br />
47. public void paint( Graphics g ) {<br />
48. Rectangle bounds = getBounds();<br />
49. int x = 0;<br />
50. int y = 0;<br />
51. int w = bounds.width - 1;<br />
52. int h = bounds. height - 1;<br />
53. for ( int i = 0; i < 10; i++ ) {<br />
54. g.drawOval( x, y, w, h );<br />
55. x += 10;<br />
56. y += 10;<br />
57. w -= 20;<br />
58. h -= 20;<br />
59. }<br />
60. }<br />
61. }