TAILIEUCHUNG - core java volume 1 fundamental 8th edition 2008 phần 5

Thanh trượt thứ tư trong Hình 9-18 đã không theo dõi. Để ngăn chặn "theo dõi" trong đó di chuyển thanh trượt, gọiThanh trượt thứ năm có hướng của nó đảo ngược bởi một cuộc gọi đến (true);Thành phần giao diện người dùng với Swing | Chapter 7. Graphics Programming Simpo PDF Merge and Split Unregistered Version - http Displaying Images 319 Figure 7-14 Window with tiled graphics image Listing 7-6 1. import . 2. import . 3. import . 4. import . 5. 6. 7. aversion 2007-04-14 8. @author Cay Horstmann 9. 10. public class ImageTest 11. 12. public static void main String args 13. 14. new Runnable 15. 16. public void run 17. 18. ImageFrame frame new ImageFrame 19. 20. true 21. 22. 23. 24. 25. 26. 27. A frame with an image component 28. 29. class ImageFrame extends JFrame 30. 31. public ImageFrame 32. 33. setTitle ImageTest 34. setSize DEFAULT_WIDTH DEFAULT_HEIGHT 35. Chapter 7. Graphics Programming Simpo PDF Merge and Split Unregistered Version - http 320 Chapter 7 Graphics Programming Listing 7-6 continued 36. add component to frame 37. 38. ImageComponent component new ImageComponent 39. add component 40. 41. 42. public static final int DEFAULT_WIDTH 300 43. public static final int DEFAULT_HEIGHT 200 44. 45. 46. 47. A component that displays a tiled image 48. 49. class ImageComponent extends JComponent 50. 51. public ImageComponent 52. 53. acquire the image 54. try 55. 56. image new File 57. 58. catch IOException e 59. 60. 61. 62. 63. 64. public void paintComponent Graphics g 65. 66. if image null return 67. 68. int imageWidth this 69. int imageHeight this 70. 71. draw the image in the top-left corner 72. 73. image 0 0 null 74. tile the image across the component 75. 76. for int i 0 i imageWidth getWidth i 77. for int j 0 j imageHeight getHeight j 78. if i j 0 0 0 imageWidth imageHeight i imageWidth j 79. imageHeight 80. 81. 82. private Image image 83. Chapter 7. Graphics Programming Simpo PDF Merge and Split

TỪ KHÓA LIÊN QUAN
Đã 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.