0

I have a JFrame and it opens java Print Dialog.Like below

 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. 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.

But how to know my print dilaog is opened ?

Because pj.printDialog() is waiting.

How to get the print dilaog opened event ?

nihasmata
  • 652
  • 1
  • 8
  • 28
  • Have you tried just putting it before and after that block of code? It might work fine to just wait until after it prints to revert the setting – phflack Nov 21 '17 at 13:44

1 Answers1

0

You can use printrequestAttributeSet object to brint printer dialog on top. For example;

PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
set.add(OrientationRequested.LANDSCAPE);
set.add(new sun.print.DialogOnTop());

Then , use

pj.printDialog(set)
engtuncay
  • 867
  • 10
  • 29