- java.lang.Object
- 
- java.awt.PageAttributes
 
- 
- All Implemented Interfaces:
- Cloneable
 
 public final class PageAttributes extends Object implements Cloneable A set of attributes which control the output of a printed page.Instances of this class control the color state, paper size (media type), orientation, logical origin, print quality, and resolution of every page which uses the instance. Attribute names are compliant with the Internet Printing Protocol (IPP) 1.1 where possible. Attribute values are partially compliant where possible. To use a method which takes an inner class type, pass a reference to one of the constant fields of the inner class. Client code cannot create new instances of the inner class types because none of those classes has a public constructor. For example, to set the color state to monochrome, use the following code: import java.awt.PageAttributes; public class MonochromeExample { public void setMonochrome(PageAttributes pageAttributes) { pageAttributes.setColor(PageAttributes.ColorType.MONOCHROME); } }Every IPP attribute which supports an attributeName-default value has a corresponding setattributeNameToDefaultmethod. Default value fields are not provided.- Since:
- 1.3
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classPageAttributes.ColorTypeA type-safe enumeration of possible color states.static classPageAttributes.MediaTypeA type-safe enumeration of possible paper sizes.static classPageAttributes.OrientationRequestedTypeA type-safe enumeration of possible orientations.static classPageAttributes.OriginTypeA type-safe enumeration of possible origins.static classPageAttributes.PrintQualityTypeA type-safe enumeration of possible print qualities.
 - 
Constructor SummaryConstructors Constructor Description PageAttributes()Constructs a PageAttributes instance with default values for every attribute.PageAttributes(PageAttributes obj)Constructs a PageAttributes instance which is a copy of the supplied PageAttributes.PageAttributes(PageAttributes.ColorType color, PageAttributes.MediaType media, PageAttributes.OrientationRequestedType orientationRequested, PageAttributes.OriginType origin, PageAttributes.PrintQualityType printQuality, int[] printerResolution)Constructs a PageAttributes instance with the specified values for every attribute.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Creates and returns a copy of this PageAttributes.booleanequals(Object obj)Determines whether two PageAttributes are equal to each other.PageAttributes.ColorTypegetColor()Returns whether pages using these attributes will be rendered in color or monochrome.PageAttributes.MediaTypegetMedia()Returns the paper size for pages using these attributes.PageAttributes.OrientationRequestedTypegetOrientationRequested()Returns the print orientation for pages using these attributes.PageAttributes.OriginTypegetOrigin()Returns whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area.int[]getPrinterResolution()Returns the print resolution for pages using these attributes.PageAttributes.PrintQualityTypegetPrintQuality()Returns the print quality for pages using these attributes.inthashCode()Returns a hash code value for this PageAttributes.voidset(PageAttributes obj)Sets all of the attributes of this PageAttributes to the same values as the attributes of obj.voidsetColor(PageAttributes.ColorType color)Specifies whether pages using these attributes will be rendered in color or monochrome.voidsetMedia(PageAttributes.MediaType media)Specifies the desired paper size for pages using these attributes.voidsetMediaToDefault()Sets the paper size for pages using these attributes to the default size for the default locale.voidsetOrientationRequested(int orientationRequested)Specifies the print orientation for pages using these attributes.voidsetOrientationRequested(PageAttributes.OrientationRequestedType orientationRequested)Specifies the print orientation for pages using these attributes.voidsetOrientationRequestedToDefault()Sets the print orientation for pages using these attributes to the default.voidsetOrigin(PageAttributes.OriginType origin)Specifies whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area.voidsetPrinterResolution(int printerResolution)Specifies the desired cross feed and feed print resolutions in dots per inch for pages using these attributes.voidsetPrinterResolution(int[] printerResolution)Specifies the desired print resolution for pages using these attributes.voidsetPrinterResolutionToDefault()Sets the printer resolution for pages using these attributes to the default.voidsetPrintQuality(int printQuality)Specifies the print quality for pages using these attributes.voidsetPrintQuality(PageAttributes.PrintQualityType printQuality)Specifies the print quality for pages using these attributes.voidsetPrintQualityToDefault()Sets the print quality for pages using these attributes to the default.StringtoString()Returns a string representation of this PageAttributes.
 
- 
- 
- 
Constructor Detail- 
PageAttributespublic PageAttributes() Constructs a PageAttributes instance with default values for every attribute.
 - 
PageAttributespublic PageAttributes(PageAttributes obj) Constructs a PageAttributes instance which is a copy of the supplied PageAttributes.- Parameters:
- obj- the PageAttributes to copy.
 
 - 
PageAttributespublic PageAttributes(PageAttributes.ColorType color, PageAttributes.MediaType media, PageAttributes.OrientationRequestedType orientationRequested, PageAttributes.OriginType origin, PageAttributes.PrintQualityType printQuality, int[] printerResolution) Constructs a PageAttributes instance with the specified values for every attribute.- Parameters:
- color- ColorType.COLOR or ColorType.MONOCHROME.
- media- one of the constant fields of the MediaType class.
- orientationRequested- OrientationRequestedType.PORTRAIT or OrientationRequestedType.LANDSCAPE.
- origin- OriginType.PHYSICAL or OriginType.PRINTABLE
- printQuality- PrintQualityType.DRAFT, PrintQualityType.NORMAL, or PrintQualityType.HIGH
- printerResolution- an integer array of 3 elements. The first element must be greater than 0. The second element must be must be greater than 0. The third element must be either- 3or- 4.
- Throws:
- IllegalArgumentException- if one or more of the above conditions is violated.
 
 
- 
 - 
Method Detail- 
clonepublic Object clone() Creates and returns a copy of this PageAttributes.
 - 
setpublic void set(PageAttributes obj) Sets all of the attributes of this PageAttributes to the same values as the attributes of obj.- Parameters:
- obj- the PageAttributes to copy.
 
 - 
getColorpublic PageAttributes.ColorType getColor() Returns whether pages using these attributes will be rendered in color or monochrome. This attribute is updated to the value chosen by the user.- Returns:
- ColorType.COLOR or ColorType.MONOCHROME.
 
 - 
setColorpublic void setColor(PageAttributes.ColorType color) Specifies whether pages using these attributes will be rendered in color or monochrome. Not specifying this attribute is equivalent to specifying ColorType.MONOCHROME.- Parameters:
- color- ColorType.COLOR or ColorType.MONOCHROME.
- Throws:
- IllegalArgumentException- if color is null.
 
 - 
getMediapublic PageAttributes.MediaType getMedia() Returns the paper size for pages using these attributes. This attribute is updated to the value chosen by the user.- Returns:
- one of the constant fields of the MediaType class.
 
 - 
setMediapublic void setMedia(PageAttributes.MediaType media) Specifies the desired paper size for pages using these attributes. The actual paper size will be determined by the limitations of the target printer. If an exact match cannot be found, an implementation will choose the closest possible match. Not specifying this attribute is equivalent to specifying the default size for the default locale. The default size for locales in the United States and Canada is MediaType.NA_LETTER. The default size for all other locales is MediaType.ISO_A4.- Parameters:
- media- one of the constant fields of the MediaType class.
- Throws:
- IllegalArgumentException- if media is null.
 
 - 
setMediaToDefaultpublic void setMediaToDefault() Sets the paper size for pages using these attributes to the default size for the default locale. The default size for locales in the United States and Canada is MediaType.NA_LETTER. The default size for all other locales is MediaType.ISO_A4.
 - 
getOrientationRequestedpublic PageAttributes.OrientationRequestedType getOrientationRequested() Returns the print orientation for pages using these attributes. This attribute is updated to the value chosen by the user.- Returns:
- OrientationRequestedType.PORTRAIT or OrientationRequestedType.LANDSCAPE.
 
 - 
setOrientationRequestedpublic void setOrientationRequested(PageAttributes.OrientationRequestedType orientationRequested) Specifies the print orientation for pages using these attributes. Not specifying the property is equivalent to specifying OrientationRequestedType.PORTRAIT.- Parameters:
- orientationRequested- OrientationRequestedType.PORTRAIT or OrientationRequestedType.LANDSCAPE.
- Throws:
- IllegalArgumentException- if orientationRequested is null.
 
 - 
setOrientationRequestedpublic void setOrientationRequested(int orientationRequested) Specifies the print orientation for pages using these attributes. Specifying3denotes portrait. Specifying4denotes landscape. Specifying any other value will generate an IllegalArgumentException. Not specifying the property is equivalent to calling setOrientationRequested(OrientationRequestedType.PORTRAIT).- Parameters:
- orientationRequested-- 3or- 4
- Throws:
- IllegalArgumentException- if orientationRequested is not- 3or- 4
 
 - 
setOrientationRequestedToDefaultpublic void setOrientationRequestedToDefault() Sets the print orientation for pages using these attributes to the default. The default orientation is portrait.
 - 
getOriginpublic PageAttributes.OriginType getOrigin() Returns whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area. (Note that these locations could be equivalent.) This attribute cannot be modified by, and is not subject to any limitations of, the implementation or the target printer.- Returns:
- OriginType.PHYSICAL or OriginType.PRINTABLE
 
 - 
setOriginpublic void setOrigin(PageAttributes.OriginType origin) Specifies whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area. (Note that these locations could be equivalent.) Not specifying the property is equivalent to specifying OriginType.PHYSICAL.- Parameters:
- origin- OriginType.PHYSICAL or OriginType.PRINTABLE
- Throws:
- IllegalArgumentException- if origin is null.
 
 - 
getPrintQualitypublic PageAttributes.PrintQualityType getPrintQuality() Returns the print quality for pages using these attributes. This attribute is updated to the value chosen by the user.- Returns:
- PrintQualityType.DRAFT, PrintQualityType.NORMAL, or PrintQualityType.HIGH
 
 - 
setPrintQualitypublic void setPrintQuality(PageAttributes.PrintQualityType printQuality) Specifies the print quality for pages using these attributes. Not specifying the property is equivalent to specifying PrintQualityType.NORMAL.- Parameters:
- printQuality- PrintQualityType.DRAFT, PrintQualityType.NORMAL, or PrintQualityType.HIGH
- Throws:
- IllegalArgumentException- if printQuality is null.
 
 - 
setPrintQualitypublic void setPrintQuality(int printQuality) Specifies the print quality for pages using these attributes. Specifying3denotes draft. Specifying4denotes normal. Specifying5denotes high. Specifying any other value will generate an IllegalArgumentException. Not specifying the property is equivalent to calling setPrintQuality(PrintQualityType.NORMAL).- Parameters:
- printQuality-- 3,- 4, or- 5
- Throws:
- IllegalArgumentException- if printQuality is not- 3,- 4, or- 5
 
 - 
setPrintQualityToDefaultpublic void setPrintQualityToDefault() Sets the print quality for pages using these attributes to the default. The default print quality is normal.
 - 
getPrinterResolutionpublic int[] getPrinterResolution() Returns the print resolution for pages using these attributes. Index 0 of the array specifies the cross feed direction resolution (typically the horizontal resolution). Index 1 of the array specifies the feed direction resolution (typically the vertical resolution). Index 2 of the array specifies whether the resolutions are in dots per inch or dots per centimeter.3denotes dots per inch.4denotes dots per centimeter.- Returns:
- an integer array of 3 elements. The first
          element must be greater than 0. The second element must be
          must be greater than 0. The third element must be either
          3or4.
 
 - 
setPrinterResolutionpublic void setPrinterResolution(int[] printerResolution) Specifies the desired print resolution for pages using these attributes. The actual resolution will be determined by the limitations of the implementation and the target printer. Index 0 of the array specifies the cross feed direction resolution (typically the horizontal resolution). Index 1 of the array specifies the feed direction resolution (typically the vertical resolution). Index 2 of the array specifies whether the resolutions are in dots per inch or dots per centimeter.3denotes dots per inch.4denotes dots per centimeter. Note that the 1.1 printing implementation (Toolkit.getPrintJob) requires that the feed and cross feed resolutions be the same. Not specifying the property is equivalent to calling setPrinterResolution(72).- Parameters:
- printerResolution- an integer array of 3 elements. The first element must be greater than 0. The second element must be must be greater than 0. The third element must be either- 3or- 4.
- Throws:
- IllegalArgumentException- if one or more of the above conditions is violated.
 
 - 
setPrinterResolutionpublic void setPrinterResolution(int printerResolution) Specifies the desired cross feed and feed print resolutions in dots per inch for pages using these attributes. The same value is used for both resolutions. The actual resolutions will be determined by the limitations of the implementation and the target printer. Not specifying the property is equivalent to specifying72.- Parameters:
- printerResolution- an integer greater than 0.
- Throws:
- IllegalArgumentException- if printerResolution is less than or equal to 0.
 
 - 
setPrinterResolutionToDefaultpublic void setPrinterResolutionToDefault() Sets the printer resolution for pages using these attributes to the default. The default is 72 dpi for both the feed and cross feed resolutions.
 - 
equalspublic boolean equals(Object obj) Determines whether two PageAttributes are equal to each other.Two PageAttributes are equal if and only if each of their attributes are equal. Attributes of enumeration type are equal if and only if the fields refer to the same unique enumeration object. This means that an aliased media is equal to its underlying unique media. Printer resolutions are equal if and only if the feed resolution, cross feed resolution, and units are equal. - Overrides:
- equalsin class- Object
- Parameters:
- obj- the object whose equality will be checked.
- Returns:
- whether obj is equal to this PageAttribute according to the above criteria.
- See Also:
- Object.hashCode(),- HashMap
 
 - 
hashCodepublic int hashCode() Returns a hash code value for this PageAttributes.- Overrides:
- hashCodein class- Object
- Returns:
- the hash code.
- See Also:
- Object.equals(java.lang.Object),- System.identityHashCode(java.lang.Object)
 
 
- 
 
-