-
Bug
-
Resolution: Fixed
-
P3
-
6u26
-
b137
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20)
ADDITIONAL OS VERSION INFORMATION :
windows xp service pack
A DESCRIPTION OF THE PROBLEM :
In PrinterJob , the api PrinterJob#pageDialog() , will give jdk pageFormate dialog to change pageFormate settings like orientation and page Formate , page margins .
once pageDialog was shown , switch to some other applciation , and come back , this time only pageDailog is showing with out main appication .
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create any gui appication for print supporting ,and print preview before print
2. provide a option for selecting pageSetup dialog in preview panel
3. click on that , then pageFormate(pagesetup) Dailog will open , on top of application
4. Dont close that dialog and switch to some another application
5 come back to gui appication , now the appication is not showing , only pageFormateDailog is showing .
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1. The pagesetup dialog should always shown on top of gui application even after switching to some other application and come back to gui application (means the application can act as parent to pagesetupadialog)
ACTUAL -
After switching to another application and come back to main gui application only Pagesetup Dailog is showing with out main gui application visibility.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.huawei.iview.templates.print;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class PrintDialogExample implements Printable
{
public int print(Graphics g , PageFormat pf , int page)
throws PrinterException
{
if (page > 0)
{ /* We have only one page, and 'page' is zero-based */
return NO_SUCH_PAGE;
}
/*
* User (0,0) is typically outside the imageable area, so we must
* translate by the X and Y values in the PageFormat to avoid clipping
*/
Graphics2D g2d = (Graphics2D) g;
g2d.translate(pf.getImageableX() , pf.getImageableY());
/* Now we perform our rendering */
g.drawString("Test the print dialog!" , 100 , 100);
/* tell the caller that this page is part of the printed document */
return PAGE_EXISTS;
}
public static void main(String args[])
{
JFrame frame = new JFrame("hello");
JPanel panel = new JPanel();
JButton button = new JButton("preview");
panel.add(button , BorderLayout.CENTER);
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
try
{
String cn = UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(cn); // Use the native L&F
}
catch (Exception cnf)
{
}
PrinterJob job = PrinterJob.getPrinterJob();
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PageFormat pf = job.pageDialog(aset);
job.setPrintable(new PrintDialogExample() , pf);
boolean ok = job.printDialog(aset);
if (ok)
{
try
{
job.print(aset);
}
catch (PrinterException ex)
{
/* The job did not successfully complete */
}
}
System.exit(0);
}
});
frame.getContentPane().add(panel);
frame.setSize(500,500);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
SUPPORT :
YES
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20)
ADDITIONAL OS VERSION INFORMATION :
windows xp service pack
A DESCRIPTION OF THE PROBLEM :
In PrinterJob , the api PrinterJob#pageDialog() , will give jdk pageFormate dialog to change pageFormate settings like orientation and page Formate , page margins .
once pageDialog was shown , switch to some other applciation , and come back , this time only pageDailog is showing with out main appication .
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create any gui appication for print supporting ,and print preview before print
2. provide a option for selecting pageSetup dialog in preview panel
3. click on that , then pageFormate(pagesetup) Dailog will open , on top of application
4. Dont close that dialog and switch to some another application
5 come back to gui appication , now the appication is not showing , only pageFormateDailog is showing .
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1. The pagesetup dialog should always shown on top of gui application even after switching to some other application and come back to gui application (means the application can act as parent to pagesetupadialog)
ACTUAL -
After switching to another application and come back to main gui application only Pagesetup Dailog is showing with out main gui application visibility.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.huawei.iview.templates.print;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class PrintDialogExample implements Printable
{
public int print(Graphics g , PageFormat pf , int page)
throws PrinterException
{
if (page > 0)
{ /* We have only one page, and 'page' is zero-based */
return NO_SUCH_PAGE;
}
/*
* User (0,0) is typically outside the imageable area, so we must
* translate by the X and Y values in the PageFormat to avoid clipping
*/
Graphics2D g2d = (Graphics2D) g;
g2d.translate(pf.getImageableX() , pf.getImageableY());
/* Now we perform our rendering */
g.drawString("Test the print dialog!" , 100 , 100);
/* tell the caller that this page is part of the printed document */
return PAGE_EXISTS;
}
public static void main(String args[])
{
JFrame frame = new JFrame("hello");
JPanel panel = new JPanel();
JButton button = new JButton("preview");
panel.add(button , BorderLayout.CENTER);
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
try
{
String cn = UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(cn); // Use the native L&F
}
catch (Exception cnf)
{
}
PrinterJob job = PrinterJob.getPrinterJob();
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PageFormat pf = job.pageDialog(aset);
job.setPrintable(new PrintDialogExample() , pf);
boolean ok = job.printDialog(aset);
if (ok)
{
try
{
job.print(aset);
}
catch (PrinterException ex)
{
/* The job did not successfully complete */
}
}
System.exit(0);
}
});
frame.getContentPane().add(panel);
frame.setSize(500,500);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
SUPPORT :
YES