The dialogs follow a standard pattern of acting as a continue/cancel option for a user as well as allowing the user to select the print service to use and specify choices such as paper size and number of copies.
The dialogs are designed to work with pluggable print services though the public APIs of those print services.
If a print service provides any vendor extensions these may be made
accessible to the user through a vendor supplied tab panel Component.
Such a vendor extension is encouraged to use Swing! and to support its
accessibility APIs. The vendor extensions should return the settings as part
of the AttributeSet. Applications which want to preserve the user
settings should use those settings to specify the print job. Note that this
class is not referenced by any other part of the Java Print Service and may
not be included in profiles which cannot depend on the presence of the AWT
packages.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static PrintService | Returns: print service selected by the user, ornull if the user
cancelled the dialogused to select screen, gc, int null means primary or default
screenlocation of dialog including border in screen coordinates
relative to the origin of x, int gclocation of dialog including border in screen coordinates
relative to the origin of y, PrintService[] gcto be browsable, must be services, PrintService non-nullinitial defaultService, DocFlavor PrintService to displaythe flavor to be printed, or flavor, PrintRequestAttributeSet nullon input is the initial application supplied
preferences. This cannot be attributes)null but may be empty. On
output the attributes reflect changes made by the user.Presents a dialog to the user for selecting a print service (printer). |
| private static void | removeUnsupportedAttributes(PrintService ps, DocFlavor flavor, AttributeSet aset)
Removes any attributes from the given |
| ServiceUI | back to summary |
|---|---|
| public ServiceUI() Constructs a | |
| printDialog | back to summary |
|---|---|
| public static PrintService printDialog(GraphicsConfiguration gc, int x, int y, PrintService[] services, PrintService defaultService, DocFlavor flavor, PrintRequestAttributeSet attributes) throws HeadlessException Presents a dialog to the user for selecting a print service (printer). It is displayed at the location specified by the application and is modal. If the specification is invalid or would make the dialog not visible it will be displayed at a location determined by the implementation. The dialog blocks its calling thread and is application modal.
The dialog may include a tab panel with custom UI lazily obtained from
the
The dialog returns the print service selected by the user if the user
OK's the dialog and
An application must pass in an array of print services to browse. The
array must be
An application may pass in a
An application may optionally pass in the flavor to be printed. If this
is These are used to set the initial settings for the initially displayed print service. Values which are not supported by the print service are ignored. As the user browses print services, attributes and values are copied to the new display. If a user browses a print service which does not support a particular attribute-value, the default for that service is used as the new value to be copied. If the user cancels the dialog, the returned attributes will not reflect any changes made by the user. A typical basic usage of this method may be:
| |
| removeUnsupportedAttributes | back to summary |
|---|---|
| private static void removeUnsupportedAttributes(PrintService ps, DocFlavor flavor, AttributeSet aset) Removes any attributes from the given | |