TAILIEUCHUNG - Java 6 Platform Revealed phần 6

Tham khảo tài liệu 'java 6 platform revealed phần 6', 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ả | 92 CHAPTER 4 AWT AND SWING UPDATES you were responsible for pagination and the like. Now it s all done for you you just need to call one of the new print methods of which there are three. The simplest way to print the contents of a text component is to call its no-argument print method. Figure 4-24 shows what the initial program looks like and Figure 4-25 shows the standard printer dialog. The program in Listing 4-11 simply shows a JTextArea pastes the current clipboard contents into it and offers a Print button for printing the content. Figure 4-24. Printing the contents of a text component Figure 4-25. The printer dialog CHAPTER 4 AWT AND SWING UPDATES 93 Listing 4-11. Printing Text Components import . import . import . import . public class TextPrint public static void main final String args Runnable runner new Runnable public void run JFrame frame new JFrame Text Print final JTextArea textArea new JTextArea JScrollPane pane new JScrollPane textArea pane JButton button new JButton Print button ActionListener listener new ActionListener public void actionPerformed ActionEvent e try catch PrinterException pe Unable to print. listener 250 150 true runner 94 CHAPTER 4 AWT AND SWING UPDATES The print method is itself kind of generic. While it does offer you the interactive printer-selection dialog you don t get a footer or header on each page. In order to do this you need to use the second variety of the method print MessageFormat header MessageFormat footer . The most interesting of all the print methods is the full-featured one public boolean print MessageFormat headerFormat MessageFormat footerFormat boolean showPrintDialog PrintService service PrintRequestAttributeSet attributes .

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.