Inquiry about PrintDialog Properties button behavior on Linux (JDK-8246742)

last last sakyosang at gmail.com
Fri Mar 21 06:20:24 UTC 2025


*Dear OpenJDK Community,*

I'm writing regarding an observation about the PrintDialog's Properties
button behavior on Linux platforms. On my Ubuntu 20.04 system (OpenJDK
version: 17), I noticed that the Properties button in the print dialog
remains disabled.

Through previous research, I found this is documented in JDK-8246742
("Disable Properties button in PrintDialog for Unixes and Mac"). The ticket
suggests this behavior was intentionally implemented.

But from a user perspective, this disabled state raises some concerns:

   1. 1.Users familiar with Windows implementation may find this
   inconsistent
   2. 2.Prevents access to printer-specific options that might otherwise be
   configurable
   3. 3.Could be confusing for applications relying on this functionality

Reproducer:
import java.awt.*;
import java.awt.print.*;

public class PrintDialogExample implements Printable {

    public static void main(String[] args) {
        // 创建 PrinterJob 对象
        PrinterJob printerJob = PrinterJob.getPrinterJob();

        // 设置打印内容
        printerJob.setPrintable(new PrintDialogExample());

        // 显示打印对话框
        if (printerJob.printDialog()) {
            try {
                // 执行打印任务
                printerJob.print();
                System.out.println("Printing complete.");
            } catch (PrinterException e) {
                e.printStackTrace();
            }
        } else {
            System.out.println("Printing cancelled.");
        }
    }

    @Override
    public int print(Graphics graphics, PageFormat pageFormat, int
pageIndex) throws PrinterException {
        // 只打印第一页
        if (pageIndex > 0) {
            return Printable.NO_SUCH_PAGE;
        }

        // 将 Graphics 对象转换为 Graphics2D
        Graphics2D g2d = (Graphics2D) graphics;

        // 设置字体和颜色
        g2d.setFont(new Font("Serif", Font.PLAIN, 12));
        g2d.setColor(Color.BLACK);

        // 打印文本
        String text = "Hello, this is a test print job!";
        g2d.drawString(text, 100, 100);

        // 返回打印成功
        return Printable.PAGE_EXISTS;
    }
}


I'd like to inquire:

   1. 1.Is this considered an accepted platform behavior difference?
   2. 2.Are there any plans to implement native printer property support
   for Linux/MacOS?
   3. 3.Would there be value in creating a feature request for this
   capability?

Additional environment details:

   - Desktop Environment: GNOME [3.34.3-0ubuntu1 ]
   - Default Print System: CUPS [2.3.1-9ubuntu1.4]

Thank you for your insights. I'm happy to provide further testing support
if needed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jdk-dev/attachments/20250321/1625abc0/attachment.htm>


More information about the jdk-dev mailing list