JDK-8203834 : Define API to support specifying ownership of print dialogs.
  • Type: CSR
  • Component: client-libs
  • Sub-Component: 2d
  • Priority: P2
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 11
  • Submitted: 2018-05-25
  • Updated: 2018-06-18
  • Resolved: 2018-06-06
Related Reports
CSR :  
Description
Summary
-------
Define a new PrintRequestAttribute which can specify the
print dialog owner window or on top behavior.

Problem
-------

JavaFX has been using internal JDK API provided for it to
be able to specify an owner window, or failing that "always
on top" behaviour  when invoking the Java 2D PrinterJob's 
print and page dialogs. This was possible when JavaFX was
part of the JDK. Now it is separate, this will no longer work
unless applications specify on the command line the
export of an internal printing package from the java.desktop module

Solution
--------

When displaying the print or page dialog for a java.awt.print.PrinterJob,
the PrintRequestAttributeSet parameter may optionally contain a new DialogOwner attribute which
applications can use to specify one of
- an owner AWT window
- AWT "alwaysOnTop" behaviour.

Also define an undocumented non-SE interface to be used by JavaFX from native code for
supplying a native Window handle for an owner window using JNI.

Specification
-------------

Define a new class in package javax.print.attribute.standard :
<pre>


/**
 * An attribute class used to support requesting a print or page setup dialog
 * be kept displayed on top of all windows or some specific window.
 * <p>
 * Constructed without any arguments it will request that a print or page
 * setup dialog be configured as if the application directly was to specify
 * {@code java.awt.Window.setAlwaysOnTop(true)}, subject to permission checks.
 * <p>
 * Constructed with a {@link java.awt.Window} parameter, it requests that
 * the dialog be owned by the specified window.
 * @since 11
 */

public final class DialogOwner implements PrintRequestAttribute {
   /**
     * Constructs an instance which can be used to request
     * {@code java.awt.Window.setAlwaysOnTop(true)} behaviour.
     * This should be used where there is no application preferred owner window.
     * Whether this has any effect depends on if always on top is supported
     * for this platform and the particular dialog to be displayed.
     */
    public DialogOwner();

    /**
     * Constructs an instance which can be used to request that the
     * specified {@link java.awt.Window} be the owner of the dialog.
     * @param owner window.
     */
    public DialogOwner(Window owner) {

    /**
     * Returns a {@code Window owner}, if one was specified,
     * otherwise {@code null}.
     * @return an owner window.
     */
     public Window getOwner();

    /**
     * Get the printing attribute class which is to be used as the "category"
     * for this printing attribute value.
     * <p>
     * For class {@code DialogOwner}, the category is class
     * {@code DialogOwner} itself.
     *
     * @return printing attribute class (category), an instance of class
     *         {@link Class java.lang.Class}
     */ 
    public final Class<? extends Attribute> getCategory();

  /**
     * Get the name of the category of which this attribute value is an
     * instance.
     * <p>
     * For class {@code DialogOwner}, the category name is
     * {@code "dialog-owner"}.
     *
     */
    public final String getName();

}
</pre>


------

Additionally to the above SE API JavaFX will use JNI to call a private undocumented constructor
<pre>
/*
* Construct a DialogOwner that  specifies a non-AWT native window.
* @param id
*/
DialogOwner(long id);
</pre>
Comments
Moving to Approved.
06-06-2018