Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4514422
Votes 2
Synopsis main focus lost after closing PrinterJob.pageDialog or PrinterJob.printDialog
Category java:classes_awt
Reported Against 1.4 , merlin-beta2
Release Fixed
State 11-Closed, Not Reproducible, bug
Priority: 4-Low
Related Bugs 4784285
Submit Date 13-OCT-2001
Description




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) 
======================================================================




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)
======================================================================
Work Around
N/A
Evaluation
Focus regression; committing to hopper and tiger.
 xxxxx@xxxxx  2001-11-05

Assigning to Russia.
 xxxxx@xxxxx  2001-11-06



commit to hopper and tiger
======================================================================



The problem is not reproducible with Hopper b06 and later.
 xxxxx@xxxxx   May 28, 2002


======================================================================
Comments
  
  Include a link with my name & email   

Submitted On 18-APR-2002
potel
A related problem is that if you bring up a pageDialog (or printDialog), then cover it with a different 
application window, and then use bring your Java application back to the front using the task bar, the 
pageDialog (or printDialog) remains hidden.  Since the pageDialog (or printDialog) is modal, you are stuck 
until you uncover it.  Even if your main Java window isn't hidden by the other application window, you can't 
click on it to make it active.  A regular JDialog works properly in that you pass your parent window to the 
modal JDialog and both come to the front when activated. 


Submitted On 21-JUN-2002
weiqigao
I have observed this behavior again with
J2SE SDK 1.4.0 on Windows 2000 Pro.

Should I file a new bug report as this bug is already marked
closed?

--
Weiqi Gao
weiqigao@networkusa.net


Submitted On 27-JUN-2002
roosen
This bug is still present in JDK 1.4.0_01 on Windows 2000 
Pro, NT 4.0, and XP.  Please try again to reproduce this.  
If you cannot, we'll be glad to reproduce it for you.

I suspect some code is just off-by-one in determining what 
frame should get the focus after the system dialog is 
dismissed.

It really gives Java-based applications a black eye to have 
this kind of behavior going on.


Submitted On 16-JUL-2002
stephenmenke
I also am having the same problem with JDK 1.4.0_01 on 
Windows 2000 Pro. How does a bug ever get reopened?


Submitted On 13-AUG-2002
tropperkeg
I am having the same problem and it is really upsetting my 
customers to have this problem.  Any news of a fix Sun???


Submitted On 26-SEP-2002
sbelsly
We are migrating from 1.3.0_02 to 1.3.1_04 versions of the 
Java Plug-in to be on a supported platform and now this bug 
shows up.    


Submitted On 07-OCT-2002
oleg.sukhodolsky
This bug was closed as not reproducible because it's not reproducible in 1.4.1.


Submitted On 15-OCT-2002
reivilo1998
We have encountered the same problem with 1.3.1_04 on 
W2000 and W98 and it is really upsetting our customers and 
us by the same. It would be a good idea for Sun and the java 
language to find a fix to this bug or a work around. Any news 
about that ?


Submitted On 20-NOV-2002
jleefoster
Using 1.4 the first use does not have the error but following 
uses do. This is closed as not reproducable - I can get it 
every time (except the first, that is...).


Submitted On 18-MAY-2004
pimpf
This bug appears in version 1.4.2. too, I wonder why its 
not repoducible? What the...? Maybe not in the code 
mentionend above. Probably you shouldnt launch this 
dialog from the event queue?!


Submitted On 16-JUN-2005
datacon
reproducible on windows 2000, java 1.42



PLEASE NOTE: JDK6 is formerly known as Project Mustang