[英]Trouble with Print Dialog Focus In Java
I have a JFrame and it opens java Print Dialog.Like below 我有一个JFrame并打开了Java Print Dialog。
PrinterJob pj = PrinterJob.getPrinterJob();
if (pj.printDialog()) {
//Print
}
The problem is that my JFrame has the setAlwaysOnTop(true) attribute and Print dialog is opened in the background of the JFrame. 问题是我的JFrame具有setAlwaysOnTop(true)属性,并且在JFrame的背景中打开了“打印”对话框。 To solve this problem I want to follow such a way
为了解决这个问题,我想遵循这样的方式
Before opening Printdialog, i will set setAlwaysOnTop(false) After opening print dialog i will set setAlwaysOnTop(true) again. 在打开Printdialog之前,我将设置setAlwaysOnTop(false)在打开打印对话框后,我将再次设置setAlwaysOnTop(true)。
But how to know my print dilaog is opened ? 但是如何知道我的印刷dilaog已打开?
Because pj.printDialog() is waiting. 因为pj.printDialog()正在等待。
How to get the print dilaog opened event ? 如何获得印刷dilaog打开事件?
You can use printrequestAttributeSet object to brint printer dialog on top. 您可以使用printrequestAttributeSet对象在顶部弹出打印机对话框。 For example;
例如;
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
set.add(OrientationRequested.LANDSCAPE);
set.add(new sun.print.DialogOnTop());
Then , use 然后,使用
pj.printDialog(set)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.