< prev index next >

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

Print this page




  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
  81      * the problematic {@code PrintColorUIResource} with a plain
  82      * {@code ColorUIResource}.
  83      * <p>
  84      * Note: As a result of this method, it is not possible to write
  85      * a {@code PrintColorUIResource} to a stream and then read
  86      * back a {@code PrintColorUIResource}. This is acceptable since we
  87      * don't have a requirement for that in Swing.
  88      */
  89     private Object writeReplace() {
  90         return new ColorUIResource(this);
  91     }
  92 }


  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
  81      * the problematic {@code PrintColorUIResource} with a plain
  82      * {@code ColorUIResource}.
  83      * <p>
  84      * Note: As a result of this method, it is not possible to write
  85      * a {@code PrintColorUIResource} to a stream and then read
  86      * back a {@code PrintColorUIResource}. This is acceptable since we
  87      * don't have a requirement for that in Swing.
  88      */
  89     private Object writeReplace() {
  90         return new ColorUIResource(this);
  91     }
  92 }
< prev index next >