-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.4.0
-
x86
-
windows_nt, windows_2000
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)
======================================================================
- relates to
-
JDK-4784285 Focus of Main Application lost after closing awt.print.PrinterJob.printDialog()
-
- Resolved
-