APIdia Launch Partner
Top Description Fields Constructors Methods
sun.swing

public Class PrintColorUIResource

extends ColorUIResource
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
java.awt.Color, java.io.Serial, javax.swing.plaf.ColorUIResource

A subclass of ColorUIResource that wraps an alternate color for use during printing. Useful to replace color values that may look poor in printed output.
Author
Shannon Hickey

Field Summary

Modifier and TypeField and Description
private Color
printColor

The color to use during printing

Constructor Summary

AccessConstructor and Description
public
PrintColorUIResource(int
the color rgb value
rgb
,
Color
the alternate color for printing
printColor
)

Construct an instance for the given RGB value and alternate color to use during printing.

Method Summary

Modifier and TypeMethod and Description
public Color

Returns:

the color to use during printing
getPrintColor
()

Return the color to use during printing.

private Object
writeReplace()

Replaces this object with a plain ColorUIResource during serialization.

Field Detail

printColorback to summary
private Color printColor

The color to use during printing

Constructor Detail

PrintColorUIResourceback to summary
public PrintColorUIResource(int rgb, Color printColor)

Construct an instance for the given RGB value and alternate color to use during printing.

Parameters
rgb:int

the color rgb value

printColor:Color

the alternate color for printing

Method Detail

getPrintColorback to summary
public Color getPrintColor()

Return the color to use during printing. If no alternate color was specified on construction, this method will return this.

Returns:Color

the color to use during printing

writeReplaceback to summary
private Object writeReplace()

Replaces this object with a plain ColorUIResource during serialization. Since PrintColorUIResource resides in the sun.swing package, access can be disallowed to it by a security manager. When access is disallowed, deserialization of any object with reference to a PrintColorUIResource fails.

Since PrintColorUIResource is used only by Swing's look and feels, and we know that UI supplied colors are replaced after deserialization when the UI is re-installed, the only important aspect of the PrintColorUIResource that needs to be persisted is the fact that it is a ColorUIResource. As such, we can avoid the problem outlined above by replacing the problematic PrintColorUIResource with a plain ColorUIResource.

Note

As a result of this method, it is not possible to write a PrintColorUIResource to a stream and then read back a PrintColorUIResource. This is acceptable since we don't have a requirement for that in Swing.

Annotations
@Serial