TAILIEUCHUNG - Programming with Java, Swing and Squint phần 10

Lớp Hành trình của chúng tôi bây giờ có tất cả các biến dụ và xây dựng cần thiết, nhưng nó không có bất kỳ phương pháp. Nếu không có phương pháp, tất cả những gì chúng ta có thể làm với hành trình xây dựng và vẽ sơ đồ đáng yêu để miêu tả họ như hình 10,10. Để làm cho lớp hữu ích hơn, chúng ta cần thêm một vài | Figure The JFileChooser Open File dialog box new File will cause the dialog to start in the directory containing the program being executed. The File class is a part of the standard java libraries used to represent file path names. The construction shown here creates a new File object from the String returned by asking the method to look up a request to find the users home directory. To use the File class you will have to include an import for . in your .java file. To display the dialog associated with a JFileChooser a program must execute an invocation of the form this Invoking showOpenDialog displays the dialog box and suspends the program s execution until the user clicks Open or Cancel . The invocation returns a value indicating whether the user clicked Open or Cancel . The value returned if Open is clicked is associated with the name . Therefore programs that use this method typically include the invocation in an if statement of the form if this . code to access and process the selected file . Finally a String containing the name of the file selected by the user can be extracted from the JFileChooser using an invocation of the form .getAbsolutePath The getSelectedFile method asks the JFileChooser to return a File object describing the file chosen by the user. The getAbsolutePath method asks this File object to produce a String encoding the file s path name. A program that uses a JFileChooser and an SImage constructor to load and display an image is shown in Figure . A picture of the interface produced by this program is shown in Figure . 310 import . import squint. import . import . An image viewer that allows a user to select an image file and then displays the contents of the file on the screen public class ImageAndLikeness extends .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.