public class ServiceUI extends Object
对话遵循一个标准的模式作为一个继续/取消用户的选择以及允许用户选择打印服务使用与指定的选择如纸张大小和份数。
对话框的设计与可插拔打印服务,尽管公众的打印服务API的工作。
如果一个打印服务提供任何供应商的扩展,这些可能是通过供应商提供的标签面板组件的用户访问。鼓励这样的供应商扩展使用摆动!并支持其可访问性的接口。供应商应该返回设置的attributeset部分。要保存用户设置的应用程序应使用这些设置来指定打印作业。请注意,这个类是不是由java打印服务的任何其他部分的参考,不可以被包括在配置文件不依赖于AWT包的存在。
Constructor and Description |
---|
ServiceUI() |
Modifier and Type | Method and Description |
---|---|
static PrintService |
printDialog(GraphicsConfiguration gc, int x, int y, PrintService[] services, PrintService defaultService, DocFlavor flavor, PrintRequestAttributeSet attributes)
向用户提供一个对话框,用于选择打印服务(打印机)。
|
public static PrintService printDialog(GraphicsConfiguration gc, int x, int y, PrintService[] services, PrintService defaultService, DocFlavor flavor, PrintRequestAttributeSet attributes) throws HeadlessException
对话可能包括一个标签面板自定义UI懒洋洋地从打字的serviceuifactory当打字浏览。该对话框将试图找到一个main_uirole首先作为一个组件,然后作为一个面板。如果没有serviceuifactory或不匹配的角色自定义选项卡将空的或不可见的。
对话框返回用户选择的打印服务,如果用户确定的对话框和无效,如果用户取消对话框。
一个应用程序必须通过一个打印服务的数组来浏览。数组必须是非空的和非空的。一个典型的应用程序将只在printservices能够打印特定文档的味道传。
应用程序可以通过一个打字是最初显示。一个非空参数必须是包含在浏览服务的阵列。如果此参数为空,则由执行所选择的服务。
一个应用程序可以选择通过在要打印的味道。如果这是非空的选择提交给用户可以更好地验证对那些支持的服务。应用程序必须返回用户选择通过一个PrintRequestAttributeSet。在调用PrintRequestAttributeSet可能是空的,或可能包含应用程序指定的值。
这些用于设置最初显示的打印服务的初始设置。不支持打印服务的值将被忽略。当用户浏览打印服务,属性和值都复制到新的显示。如果用户浏览一个打印服务不支持一个特定的属性值,该服务的默认为要复制的新价值。
如果用户取消对话框,返回的属性将不会反映用户所做的任何更改。这种方法的一个典型的基本用法可能是:
PrintService[] services = PrintServiceLookup.lookupPrintServices(
DocFlavor.INPUT_STREAM.JPEG, null);
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
if (services.length > 0) {
PrintService service = ServiceUI.printDialog(null, 50, 50,
services, services[0],
null,
attributes);
if (service != null) {
... print ...
}
}
gc
用于选择屏幕。零意味着主或默认屏幕。
x
定位对话框包括边境在屏幕坐标
y
定位对话框包括边境在屏幕坐标
services
要浏览的,必须是非空。
defaultService
-初始打字显示。
flavor
-味道要打印,或空。
attributes
-供给偏好的初步应用。这不能是空的,但可能是空的。在输出的属性反映了用户的变化。
HeadlessException
-如果graphicsenvironment isheadless()返回true。
IllegalArgumentException
如果服务是null或空,或属性为空,或初始打字不在浏览服务列表。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.