Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo sách 'java™ how to program ( deitel - deitel) - phần 17', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | more about object s methods in object s online API documentation and in The Java Tutorial at the following sites java.sun.com j2se 5.0 docs api java lang Qbject.html iava.sun.com docs books tutorial iava iavaOQ objectclass Recall from Chapter 7 that arrays are objects. As a result like all other objects an array inherits the members of class object. Note that arrays have an overridden clone method that copies the array. However if the array stores references to objects the objects are not copied. For more information about the relationship between arrays and class object please see Java Language Specification Chapter 10 at java.sun.com docs books jls second edition html arrays.doc.html PREV NEXT PREY NEXT Page 453 9.8. Optional GUI and Graphics Case Study Displaying Text and Images Using Labels Programs often use labels when they need to display information or instructions to the user in a graphical user interface. Labels are a convenient way of keeping the user informed about the current state of a program. In Java an object of class jLabei from package javax.swing can display a single line of text an image or both. The example in Fig. 9.19 demonstrates several JLabei features. Lines 36 import the classes we need to display jLabeis. BorderLayout from package java.awt contains constants that specify where we can place GUI components in the jFrame. Class imageicon represents an image that can be displayed on a JLabei and class JFrame represents the window that will contain all the labels. Line 13 creates a JLabei that displays its constructor argumentthe string North . Line 16 declares local variable iabeiicon and assigns it a new imageicon. The constructor for imageicon receives a string that specifies the path to the image. Since we only specify a file name Java assumes that it is in the same directory as class LabeiDemo. imageicon can load images in GIF JPEG and PNG image formats. Line 19 declares and initializes local variable centerLabei with a JLabei that .