In our actual work, it is often necessary to implement the printing function. But for historical reasons, the printing capabilities provided by Java have been weak. In fact, the original jdk did not support printing at all, until jdk1.1 introduced very lightweight printing support. Therefore, in the previous Java/Applet/JSP/Servlet design program, more complicated printing is realized by calling AcTIveX/OCX control or VB/VC program, which is very troublesome.
In fact, Sun has also been working on the perfection of Java printing, and the Java2 platform has finally come to the beginning of a robust printing model that is fully integrated with the Java2D graphics package. Even more encouraging is the new release of jdk1.4, which provides a complete set of Java Print Service APIs that complement the existing printing capabilities. With it, we can achieve most practical application needs, including printing text, graphics, files and print previews. This article will use a specific program example to illustrate how to design a Java print program to implement these functions, and to analyze and compare different versions of the implementation. I hope everyone can get some useful tips from it.
Printing in Java2.1 Java Print API
Java's printing API mainly exists in the java.awt.print package. The new classes in jdk1.4 mainly exist in the javax.print package and its corresponding sub-packages javax.print.event and javax.print.attribute. The javax.print package mainly contains related classes for the print service, while javax.print.event contains definitions for print events, and javax.print.attribute includes a list of available attributes for the print service.
2.2 How to achieve printing
To produce a print, you need to consider at least two:
Need a print service object. This can be done in three ways: in versions prior to jdk1.4, you must implement the java.awt.print.Printable interface or get the print service object via Toolkit.getDefaultToolkit().getPrintJob; in jdk1.4 you can also Find a print service object by javax.print.PrintSerivceLookup.
Need to start a print job. There are also several ways to do this: before jdk1.4 you can start the print job by calling the print or printAll method via java.awt.print.PrintJob (provided by jdk1.1, which is rarely used now); you can also use java.awt The printDialog of .print.PrinterJob displays the print dialog and then starts printing with the print method; in jdk1.4 you can display the print dialog via the printDialog of javax.print.ServiceUI and then call the print method to start a print job.
2.3 Printer Dialog
2.3.1 Printable Print Dialog
A print dialog can be displayed via PrinterJob.printDialog before starting the print job. It gives the user an opportunity to select the range of page numbers that should be printed and allows the user to change the print settings. It is a local dialog.
In fact, when doing a print job from a Printable object, the print object doesn't know how many pages to print. It just keeps calling the print method. As long as the print method returns a Printable.PAGE_EXISTS value, the print job will continue to produce a printed page until the print method returns Printable.NO_SUCH_PAGE, and the print job stops.
Since the print job only performs accurate page count calculations after printing is completed, the page number range on the dialog box is not yet initialized [1,9999]. We can pass to the print object by constructing a java.awt.print.Book object; we can also calculate the number of pages to be printed and pass it to the print object in the specified format to know exactly how many pages to print.
2.3.2 ServiceUI Print Dialog
Unlike the Printable dialog, the default behavior of the printer dialog that provides ServiceUI in jdk1.4 has been changed with the new API: the dialog is not displayed by default. We must use the ServiceUI class to call the printDialog method to create a print dialog like the one shown below.
The utility model provides a disposable electronic cigarette, comprising: a hollow shell, the bottom of the shell is provided with a lower cover; the shell contains an atomizer, and the outer side of the atomizer is sheathed with a disposable cigarette A bomb, a microphone cover is arranged under the atomizer, a microphone is covered under the microphone cover, a battery is arranged on one side of the atomizer, and an upper cover is arranged on the top of the casing; The atomizer includes an atomizing core, an oil-absorbing cotton sleeved on the outside of the atomizing core, and an atomizer outer tube sleeved on the outside of the oil-absorbing cotton. The disposable electronic cigarette provided by the utility model absorbs the smoke oil on the surface through the absorbing cotton, and then atomizes the smoke through the atomizing core, which greatly reduces the risk of oil leakage, at the same time, reduces the burning of cotton and ensures the smoking taste.The utility model provides a disposable electronic cigarette, comprising: a hollow shell, the bottom of the shell is provided with a lower cover; the shell contains an atomizer, and the outer side of the atomizer is sheathed with a disposable cigarette A bomb, a microphone cover is arranged under the atomizer, a microphone is covered under the microphone cover, a battery is arranged on one side of the atomizer, and an upper cover is arranged on the top of the casing; The atomizer includes an atomizing core, an oil-absorbing cotton sleeved on the outside of the atomizing core, and an atomizer outer tube sleeved on the outside of the oil-absorbing cotton. The disposable electronic cigarette provided by the utility model absorbs the smoke oil on the surface through the absorbing cotton, and then atomizes the smoke through the atomizing core, which greatly reduces the risk of oil leakage, at the same time, reduces the burning of cotton and ensures the smoking taste.The utility model provides a disposable electronic cigarette, comprising: a hollow shell, the bottom of the shell is provided with a lower cover; the shell contains an atomizer, and the outer side of the atomizer is sheathed with a disposable cigarette A bomb, a microphone cover is arranged under the atomizer, a microphone is covered under the microphone cover, a battery is arranged on one side of the atomizer, and an upper cover is arranged on the top of the casing; The atomizer includes an atomizing core, an oil-absorbing cotton sleeved on the outside of the atomizing core, and an atomizer outer tube sleeved on the outside of the oil-absorbing cotton. The disposable electronic cigarette provided by the utility model absorbs the smoke oil on the surface through the absorbing cotton, and then atomizes the smoke through the atomizing core, which greatly reduces the risk of oil leakage, at the same time, reduces the burning of cotton and ensures the smoking taste.
maskking vape,maskking vape price,maskking vape review,maskking vape shop,,maskking vape cost,maskking vape disposable,maskking vape informacion
Suizhou simi intelligent technology development co., LTD , https://www.msmsmart.com