< prev index next >

src/java.desktop/share/classes/sun/swing/PrintColorUIResource.java

Print this page




  40 public class PrintColorUIResource extends ColorUIResource {
  41 
  42     /** The color to use during printing */
  43     private Color printColor;
  44 
  45     /**
  46      * Construct an instance for the given RGB value and
  47      * alternate color to use during printing.
  48      *
  49      * @param rgb the color rgb value
  50      * @param printColor the alternate color for printing
  51      */
  52     public PrintColorUIResource(int rgb, Color printColor) {
  53         super(rgb);
  54         this.printColor = printColor;
  55     }
  56 
  57     /**
  58      * Return the color to use during printing. If no alternate
  59      * color was specified on construction, this method will
  60      * return <code>this</code>.
  61      *
  62      * @return the color to use during printing
  63      */
  64     public Color getPrintColor() {
  65         return ((printColor != null) ? printColor : this);
  66     }
  67 
  68     /**
  69      * Replaces this object with a plain {@code ColorUIResource} during
  70      * serialization. Since {@code PrintColorUIResource} resides in the
  71      * sun.swing package, access can be disallowed to it by a security
  72      * manager. When access is disallowed, deserialization of any object
  73      * with reference to a {@code PrintColorUIResource} fails.
  74      * <p>
  75      * Since {@code PrintColorUIResource} is used only by Swing's look
  76      * and feels, and we know that UI supplied colors are replaced after
  77      * deserialization when the UI is re-installed, the only important
  78      * aspect of the {@code PrintColorUIResource} that needs to be
  79      * persisted is the fact that it is a {@code ColorUIResource}. As
  80      * such, we can avoid the problem outlined above by replacing


  40 public class PrintColorUIResource extends ColorUIResource {
  41 
  42     /** The color to use during printing */
  43     private Color printColor;
  44 
  45     /**
  46      * Construct an instance for the given RGB value and
  47      * alternate color to use during printing.
  48      *
  49      * @param rgb the color rgb value
  50      * @param printColor the alternate color for printing
  51      */
  52     public PrintColorUIResource(int rgb, Color printColor) {
  53         super(rgb);
  54         this.printColor = printColor;
  55     }
  56 
  57     /**
  58      * Return the color to use during printing. If no alternate
  59      * color was specified on construction, this method will
  60      * return {@code this}.
  61      *
  62      * @return the color to use during printing
  63      */
  64     public Color getPrintColor() {
  65         return ((printColor != null) ? printColor : this);
  66     }
  67 
  68     /**
  69      * Replaces this object with a plain {@code ColorUIResource} during
  70      * serialization. Since {@code PrintColorUIResource} resides in the
  71      * sun.swing package, access can be disallowed to it by a security
  72      * manager. When access is disallowed, deserialization of any object
  73      * with reference to a {@code PrintColorUIResource} fails.
  74      * <p>
  75      * Since {@code PrintColorUIResource} is used only by Swing's look
  76      * and feels, and we know that UI supplied colors are replaced after
  77      * deserialization when the UI is re-installed, the only important
  78      * aspect of the {@code PrintColorUIResource} that needs to be
  79      * persisted is the fact that it is a {@code ColorUIResource}. As
  80      * such, we can avoid the problem outlined above by replacing
< prev index next >