- java.lang.Object
 -  
      
- java.awt.PageAttributes
 
 
-  
       
- 实现的所有接口
 -  
         
Cloneable 
public final class PageAttributes extends Object implements Cloneable
一组控制打印页面输出的属性。此类的实例控制使用该实例的每个页面的颜色状态,纸张大小(介质类型),方向,逻辑原点,打印质量和分辨率。 属性名称尽可能符合Internet打印协议(IPP)1.1。 属性值尽可能部分兼容。
要使用采用内部类类型的方法,请将引用传递给内部类的一个常量字段。 客户端代码无法创建内部类类型的新实例,因为这些类都没有公共构造函数。 例如,要将颜色状态设置为单色,请使用以下代码:
import java.awt.PageAttributes; public class MonochromeExample { public void setMonochrome(PageAttributes pageAttributes) { pageAttributes.setColor(PageAttributes.ColorType.MONOCHROME); } }支持attributeName -default值的每个IPP属性都有一个相应的
setattributeNameToDefault方法。 未提供默认值字段。- 从以下版本开始:
 - 1.3
 
 
-  
        
       
-  
             
嵌套类汇总
嵌套类 变量和类型 类 描述 static classPageAttributes.ColorType可能的颜色状态的类型安全枚举。static classPageAttributes.MediaType可能的纸张尺寸的类型安全枚举。static classPageAttributes.OrientationRequestedType类型安全的可能方向枚举。static classPageAttributes.OriginType类型安全的可能来源枚举。static classPageAttributes.PrintQualityType类型安全的可能打印质量的枚举。 
-  
             
构造方法摘要
构造方法 构造器 描述 PageAttributes()使用每个属性的默认值构造一个PageAttributes实例。PageAttributes(PageAttributes obj)构造一个PageAttributes实例,该实例是提供的PageAttributes的副本。PageAttributes(PageAttributes.ColorType color, PageAttributes.MediaType media, PageAttributes.OrientationRequestedType orientationRequested, PageAttributes.OriginType origin, PageAttributes.PrintQualityType printQuality, int[] printerResolution)使用每个属性的指定值构造一个PageAttributes实例。 
-  
             
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 Objectclone()创建并返回此PageAttributes的副本。booleanequals(Object obj)确定两个PageAttributes是否彼此相等。PageAttributes.ColorTypegetColor()返回使用这些属性的页面是以彩色还是单色呈现。PageAttributes.MediaTypegetMedia()返回使用这些属性的页面的纸张大小。PageAttributes.OrientationRequestedTypegetOrientationRequested()返回使用这些属性的页面的打印方向。PageAttributes.OriginTypegetOrigin()返回使用这些属性在(0,0)处绘制的页面是否在物理页面的左上角或可打印区域的左上角绘制。int[]getPrinterResolution()返回使用这些属性的页面的打印分辨率。PageAttributes.PrintQualityTypegetPrintQuality()返回使用这些属性的页面的打印质量。inthashCode()返回此PageAttributes的哈希码值。voidset(PageAttributes obj)将此PageAttributes的所有属性设置为与obj的属性相同的值。voidsetColor(PageAttributes.ColorType color)指定使用这些属性的页面是以彩色还是单色呈现。voidsetMedia(PageAttributes.MediaType media)为使用这些属性的页面指定所需的纸张大小。voidsetMediaToDefault()将使用这些属性的页面的纸张大小设置为默认语言环境的默认大小。voidsetOrientationRequested(int orientationRequested)指定使用这些属性的页面的打印方向。voidsetOrientationRequested(PageAttributes.OrientationRequestedType orientationRequested)指定使用这些属性的页面的打印方向。voidsetOrientationRequestedToDefault()将使用这些属性的页面的打印方向设置为默认值。voidsetOrigin(PageAttributes.OriginType origin)指定使用这些属性在(0,0)处绘制的页面是在物理页面的左上角还是在可打印区域的左上角绘制。voidsetPrinterResolution(int printerResolution)使用这些属性为页面指定所需的交叉进纸和进纸打印分辨率(以每英寸点数为单位)。voidsetPrinterResolution(int[] printerResolution)为使用这些属性的页面指定所需的打印分辨率。voidsetPrinterResolutionToDefault()将使用这些属性的页面的打印机分辨率设置为默认值。voidsetPrintQuality(int printQuality)指定使用这些属性的页面的打印质量。voidsetPrintQuality(PageAttributes.PrintQualityType printQuality)指定使用这些属性的页面的打印质量。voidsetPrintQualityToDefault()将使用这些属性的页面的打印质量设置为默认值。StringtoString()返回此PageAttributes的字符串表示形式。 
 -  
             
 
-  
        
       
-  
             
构造方法详细信息
-  
PageAttributes
public PageAttributes()
使用每个属性的默认值构造一个PageAttributes实例。 
-  
PageAttributes
public PageAttributes(PageAttributes obj)
构造一个PageAttributes实例,该实例是提供的PageAttributes的副本。- 参数
 -  
              
obj- 要复制的PageAttributes。 
 
-  
PageAttributes
public PageAttributes(PageAttributes.ColorType color, PageAttributes.MediaType media, PageAttributes.OrientationRequestedType orientationRequested, PageAttributes.OriginType origin, PageAttributes.PrintQualityType printQuality, int[] printerResolution)
使用每个属性的指定值构造一个PageAttributes实例。- 参数
 -  
              
color- ColorType.COLOR或ColorType.MONOCHROME。 -  
              
media- MediaType类的常量字段之一。 -  
              
orientationRequested- OrientationRequestedType.PORTRAIT或OrientationRequestedType.LANDSCAPE。 -  
              
origin- OriginType.PHYSICAL或OriginType.PRINTABLE -  
              
printQuality- PrintQualityType.DRAFT,PrintQualityType.NORMAL或PrintQualityType.HIGH -  
              
printerResolution- 包含3个元素的整数数组。 第一个元素必须大于0.第二个元素必须大于0.第三个元素必须是3或4。 - 异常
 -  
              
IllegalArgumentException- 如果违反上述一个或多个条件。 
 
 -  
 
-  
             
方法详细信息
-  
clone
public Object clone()
创建并返回此PageAttributes的副本。 
-  
set
public void set(PageAttributes obj)
将此PageAttributes的所有属性设置为与obj的属性相同的值。- 参数
 -  
              
obj- 要复制的PageAttributes。 
 
-  
getColor
public PageAttributes.ColorType getColor()
返回使用这些属性的页面是以彩色还是单色呈现。 此属性将更新为用户选择的值。- 结果
 - ColorType.COLOR或ColorType.MONOCHROME。
 
 
-  
setColor
public void setColor(PageAttributes.ColorType color)
指定使用这些属性的页面是以彩色还是单色呈现。 不指定此属性等同于指定ColorType.MONOCHROME。- 参数
 -  
              
color- ColorType.COLOR或ColorType.MONOCHROME。 - 异常
 -  
              
IllegalArgumentException- 如果颜色为空。 
 
-  
getMedia
public PageAttributes.MediaType getMedia()
返回使用这些属性的页面的纸张大小。 此属性将更新为用户选择的值。- 结果
 - MediaType类的常量字段之一。
 
 
-  
setMedia
public void setMedia(PageAttributes.MediaType media)
为使用这些属性的页面指定所需的纸张大小。 实际纸张尺寸将由目标打印机的限制决定。 如果找不到完全匹配,则实现将选择最接近的匹配。 不指定此属性等同于指定默认语言环境的默认大小。 美国和加拿大语言环境的默认大小为MediaType.NA_LETTER。 所有其他语言环境的默认大小为MediaType.ISO_A4。- 参数
 -  
              
media- MediaType类的常量字段之一。 - 异常
 -  
              
IllegalArgumentException- 如果media为null。 
 
-  
setMediaToDefault
public void setMediaToDefault()
将使用这些属性的页面的纸张大小设置为默认语言环境的默认大小。 美国和加拿大语言环境的默认大小为MediaType.NA_LETTER。 所有其他语言环境的默认大小为MediaType.ISO_A4。 
-  
getOrientationRequested
public PageAttributes.OrientationRequestedType getOrientationRequested()
返回使用这些属性的页面的打印方向。 此属性将更新为用户选择的值。- 结果
 - OrientationRequestedType.PORTRAIT或OrientationRequestedType.LANDSCAPE。
 
 
-  
setOrientationRequested
public void setOrientationRequested(PageAttributes.OrientationRequestedType orientationRequested)
指定使用这些属性的页面的打印方向。 不指定属性等同于指定OrientationRequestedType.PORTRAIT。- 参数
 -  
              
orientationRequested- OrientationRequestedType.PORTRAIT或OrientationRequestedType.LANDSCAPE。 - 异常
 -  
              
IllegalArgumentException- 如果orientationRequested为null。 
 
-  
setOrientationRequested
public void setOrientationRequested(int orientationRequested)
指定使用这些属性的页面的打印方向。 指定3表示肖像。 指定4表示景观。 指定任何其他值将生成IllegalArgumentException。 不指定属性等同于调用setOrientationRequested(OrientationRequestedType.PORTRAIT)。- 参数
 -  
              
orientationRequested-3或4 - 异常
 -  
              
IllegalArgumentException- 如果orientationRequested不是3或4 
 
-  
setOrientationRequestedToDefault
public void setOrientationRequestedToDefault()
将使用这些属性的页面的打印方向设置为默认值。 默认方向是纵向。 
-  
getOrigin
public PageAttributes.OriginType getOrigin()
返回使用这些属性在(0,0)处绘制的页面是否在物理页面的左上角或可打印区域的左上角绘制。 (请注意,这些位置可能是等效的。)此属性不能由实现或目标打印机修改,也不受其限制。- 结果
 - OriginType.PHYSICAL或OriginType.PRINTABLE
 
 
-  
setOrigin
public void setOrigin(PageAttributes.OriginType origin)
指定使用这些属性在(0,0)处绘制的页面是在物理页面的左上角还是在可打印区域的左上角绘制。 (请注意,这些位置可能是等效的。)不指定属性等同于指定OriginType.PHYSICAL。- 参数
 -  
              
origin- OriginType.PHYSICAL或OriginType.PRINTABLE - 异常
 -  
              
IllegalArgumentException- 如果origin为null。 
 
-  
getPrintQuality
public PageAttributes.PrintQualityType getPrintQuality()
返回使用这些属性的页面的打印质量。 此属性将更新为用户选择的值。- 结果
 - PrintQualityType.DRAFT,PrintQualityType.NORMAL或PrintQualityType.HIGH
 
 
-  
setPrintQuality
public void setPrintQuality(PageAttributes.PrintQualityType printQuality)
指定使用这些属性的页面的打印质量。 不指定属性等同于指定PrintQualityType.NORMAL。- 参数
 -  
              
printQuality- PrintQualityType.DRAFT,PrintQualityType.NORMAL或PrintQualityType.HIGH - 异常
 -  
              
IllegalArgumentException- 如果printQuality为null。 
 
-  
setPrintQuality
public void setPrintQuality(int printQuality)
指定使用这些属性的页面的打印质量。 指定3表示草稿。 指定4表示正常。 指定5表示高。 指定任何其他值将生成IllegalArgumentException。 不指定属性等同于调用setPrintQuality(PrintQualityType.NORMAL)。- 参数
 -  
              
printQuality-3,4,或5 - 异常
 -  
              
IllegalArgumentException-如果打印质量不3,4,或5 
 
-  
setPrintQualityToDefault
public void setPrintQualityToDefault()
将使用这些属性的页面的打印质量设置为默认值。 默认打印质量正常。 
-  
getPrinterResolution
public int[] getPrinterResolution()
返回使用这些属性的页面的打印分辨率。 数组的索引0指定了交叉进给方向分辨率(通常是水平分辨率)。 数组的索引1指定进纸方向分辨率(通常是垂直分辨率)。 数组的索引2指定分辨率是以每英寸点数还是每厘米点数为单位。3表示每英寸的点数。4表示每厘米的点数。- 结果
 -  
              一个包含3个元素的整数数组。 
              第一个元素必须大于0.第二个元素必须大于0.第三个元素必须是
3或4。 
 
-  
setPrinterResolution
public void setPrinterResolution(int[] printerResolution)
为使用这些属性的页面指定所需的打印分辨率。 实际分辨率将由实施和目标打印机的限制决定。 数组的索引0指定了交叉进给方向分辨率(通常是水平分辨率)。 数组的索引1指定进纸方向分辨率(通常是垂直分辨率)。 数组的索引2指定分辨率是以每英寸点数还是每厘米点数为单位。3表示每英寸的点数。4表示每厘米的点数。 请注意,1.1打印实现(Toolkit.getPrintJob)要求feed和cross feed分辨率相同。 不指定属性等同于调用setPrinterResolution(72)。- 参数
 -  
              
printerResolution- 包含3个元素的整数数组。 第一个元素必须大于0.第二个元素必须大于0.第三个元素必须是3或4。 - 异常
 -  
              
IllegalArgumentException- 如果违反上述一个或多个条件。 
 
-  
setPrinterResolution
public void setPrinterResolution(int printerResolution)
使用这些属性为页面指定所需的交叉进纸和进纸打印分辨率(以每英寸点数为单位)。 两个分辨率使用相同的值。 实际分辨率将由实施和目标打印机的限制决定。 不指定属性等同于指定72。- 参数
 -  
              
printerResolution- 大于0的整数。 - 异常
 -  
              
IllegalArgumentException- 如果printerResolution小于或等于0。 
 
-  
setPrinterResolutionToDefault
public void setPrinterResolutionToDefault()
将使用这些属性的页面的打印机分辨率设置为默认值。 Feed和交叉进纸分辨率的默认值均为72 dpi。 
-  
equals
public boolean equals(Object obj)
确定两个PageAttributes是否彼此相等。当且仅当它们的每个属性相等时,两个PageAttributes是相等的。 当且仅当字段引用相同的唯一枚举对象时,枚举类型的属性才相等。 这意味着别名媒体等于其底层唯一媒体。 当且仅当进纸分辨率,交叉进纸分辨率和单位相等时,打印机分辨率相等。
- 重写:
 -  
              
equals在类Object - 参数
 -  
              
obj- 将检查其相等性的对象。 - 结果
 - 根据上述标准,obj是否等于此PageAttribute。
 - 另请参见:
 -  
              
Object.hashCode(),HashMap 
 
-  
hashCode
public int hashCode()
返回此PageAttributes的哈希码值。- 重写:
 -  
              
hashCode在课堂上Object - 结果
 - 哈希码。
 - 另请参见:
 -  
              
Object.equals(java.lang.Object),System.identityHashCode(java.lang.Object) 
 
 -  
 
 -