JDK-4514422 : main focus lost after closing PrinterJob.pageDialog or PrinterJob.printDialog
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_nt,windows_2000
  • CPU: x86
  • Submitted: 2001-10-13
  • Updated: 2002-05-28
  • Resolved: 2002-05-28
Related Reports
Relates :  
Description

Name: ddT132432			Date: 10/12/2001


java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

{
PrinterJob prnJob = PrinterJob.getPrinterJob();
PageFormat pf = new PageFormat();
PageFormat newpf = prnJob.pageDialog(pf);
}

After the user closes the pageDialog (with OK or cancel) the main java frame
focus is lost, and instead another active (in taskbar) program pops up and
becomes the focussed application.

---------------------- Webbugs test case --------------------
//Testcase
import java.awt.*;
import java.awt.print.*;
import javax.swing.*;

class Test2 {

	public static void main(String[] args) {
		JFrame myFrame = new JFrame("Test");
		myFrame.setSize(new Dimension(200,200));
		myFrame.setVisible(true);

		//Users supplied code
		PrinterJob prnJob = PrinterJob.getPrinterJob();
		PageFormat pf = new PageFormat();
		PageFormat newpf = prnJob.pageDialog(pf);
	}

}
(Review ID: 133562) 
======================================================================

Name: jk109818			Date: 04/25/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :
Windows NT Version 4.0

ADDITIONAL OPERATING SYSTEMS :
Win 98


A DESCRIPTION OF THE PROBLEM :
Main focus is lost when a print dialog created with
PrinterJob.printDialog() is closed with either "OK"
or "Cancel" on Windows NT. On Windows 98, the print
dialog does not cause the problem, but if "print to
file" is selected, the print-to-file dialog causes
the same problem, only if cancelled. This looks
similar to bug 4514422.

REGRESSION.  Last worked in version 1.3.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Select "Go" in the dialog.
2.(NT) Cancel the dialog or
3.(98) Select "Print to file" and OK, then Cancel the
print-to-file dialog.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Expect the application to keep focus and stay on top.
Instead, focus is lost.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.event.*;
   import java.awt.print.*;
   import javax.swing.*;

   public class PrintBug extends JFrame implements
   ActionListener {
      public static void main(String[] args) {
         PrintBug instance = new PrintBug();
         instance.pack();
         instance.setVisible(true);
      }
   
      public PrintBug() {
         JButton button = new JButton("Go");
         getContentPane().add(button);
         button.addActionListener(this);
      }
   
      public void actionPerformed(ActionEvent e) {
         PrinterJob job = PrinterJob.getPrinterJob();
         job.setPrintable(
               new Printable() {
                  public int print(java.awt.Graphics graphics, PageFormat
pageFormat, int pageIndex) {
                     return NO_SUCH_PAGE;
                  } } );
         if(job.printDialog())
            try {
               job.print(); }
               catch(Exception ex) {
               }
      }
   }


---------- END SOURCE ----------

CUSTOMER WORKAROUND :
Call "toFront()" after PrinterJob.printDialog()
and PrinterJob.print() on Windows.
(Review ID: 145496)
======================================================================

Comments
EVALUATION Focus regression; committing to hopper and tiger. ###@###.### 2001-11-05 Assigning to Russia. ###@###.### 2001-11-06 Name: rpR10076 Date: 11/16/2001 commit to hopper and tiger ====================================================================== Name: osR10079 Date: 05/28/2002 The problem is not reproducible with Hopper b06 and later. ###@###.### May 28, 2002 ======================================================================
24-08-2004