Đang chuẩn bị liên kết để tải về tài liệu:
core java volume 1 fundamental 8th edition 2008 phần 5

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

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 slider.setInverted (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 www.simpopdf.com Displaying Images 319 Figure 7-14 Window with tiled graphics image Listing 7-6 ImageTest.java 1. import java.awt. 2. import java.io. 3. import javax.imageio. 4. import javax.swing. 5. 6. 7. aversion 1.33 2007-04-14 8. @author Cay Horstmann 9. 10. public class ImageTest 11. 12. public static void main String args 13. 14. EventQueue.invokeLater new Runnable 15. 16. public void run 17. 18. ImageFrame frame new ImageFrame 19. frame.setDefaultCloseOperation JFrame.EXIT_ON_CLOSE 20. frame.setVisible 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 www.simpopdf.com 320 Chapter 7 Graphics Programming Listing 7-6 ImageTest.java 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 ImageIO.read new File blue-ball.gif 57. 58. catch IOException e 59. 60. e.printStackTrace 61. 62. 63. 64. public void paintComponent Graphics g 65. 66. if image null return 67. 68. int imageWidth image.getWidth this 69. int imageHeight image.getHeight this 70. 71. draw the image in the top-left corner 72. 73. g.drawImage 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 g.copyArea 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ÀI LIỆU 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.