tailieunhanh - Introduction to Java: 17 Printing

Tham khảo tài liệu 'introduction to java: 17 printing', 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ả | In this chapter PrintGraphics Interface Printjob Class Component Methods Printing Example Printing Arbitrary Content 17 Printing Java introduces the ability to print a capability that was sadly missing inJava even though the Component class had print and printAll methods. However it is possible to print arbitrary content including multipage documents. The printing facility inJava is designed primarily to let a program print its display area or any of the components within its display. Printing is implemented with the help of one public interface PrintGraphics and one public class PrintJob of AWT. The real work is hidden behind classes provided with the toolkit for your platform. On Windows NT 95 platforms these classes are and . Other platforms have similarly named classes. Printing from an applet has security implications and is restricted by the SecurityManager. It is reasonable to suppose that a browser will make it possible to print a page containing an applet in fact Netscape has done so ever since Navigator . However this ability might not take advantage ofJava s printing facility. It isn t reasonable to suppose that an applet will be able to initiate a print job on its own. You might allow a signed applet coming from a trusted source to do so but you wouldn t want to give any random applet access to your printer. If you don t understand why imagine the potential for abuse. PrintGraphics Interface Printing is similar to drawing an object on the screen. Just as you draw onto a graphics context to display something on the screen you draw onto a printing context to create an image for printing. Furthermore the printing context and 513 514 Chapter 17 Printing graphics context are very closely related. The graphics context is an instance of the class Graphics. The printing context is also an instance of Graphics with the additional requirement that it implement the PrintGraphics interface.

TỪ KHÓA LIÊN QUAN