[macosx] Java 7 print dialog creates a new window on app-switch.

Petr Pchelko petr.pchelko at oracle.com
Tue Mar 12 12:13:08 PDT 2013


> Hi, Petr
> I assume in jdk 7 it could be fixed too?

The fix is very simple, I suppose it would be applicable to the jdk7.

With best regards. Petr.

12.03.2013, в 23:05, Sergey Bylokhov <Sergey.Bylokhov at oracle.com> написал(а):

> Hi, Abhinay.
> Thanks for your report!
> Your bug is a duplicate of 8005997, which was fixed in jdk 8.
> http://bugs.sun.com/view_bug.do?bug_id=8005997
> 
> Hi, Petr
> I assume in jdk 7 it could be fixed too?
> 
> 12.03.2013 22:41, Abhinay Reddyreddy wrote:
>> I have noticed a bug in Java 7 print dialog on Mac. I have reported it to bugs.sun.com<http://bugs.sun.com> but did not receive any response.
>> Could someone confirm if this bug has been noticed and fixed or if there is any workaround for it.
>> 
>> Thanks,
>> Abhinay.
>> 
>> Issue: An extra window is created at the top-left corner of the screen, if a user switches the app while it is showing a native print dialog.
>> 
>> Steps to reproduce:
>> Run the attached code
>> click print button
>> when the native print dialog shows up, switch to a different app using Cmd+Tab or mouse
>> switch back to the java app with print dialog
>> notice a new window is created at the top right corner of the screen.
>> 
>> java -version
>> java version "1.7.0_13"
>> Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
>> Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
>> 
>> 
>> import javax.swing.SwingUtilities;
>> import java.awt.FlowLayout;
>> import java.awt.event.ActionEvent;
>> import java.awt.event.ActionListener;
>> import java.awt.print.PrinterJob;
>> import javax.print.attribute.HashPrintRequestAttributeSet;
>> import javax.print.attribute.PrintRequestAttributeSet;
>> import javax.print.attribute.standard.DialogTypeSelection;
>> import javax.swing.JButton;
>> import javax.swing.JFrame;
>> import java.awt.print.PrinterException;
>> 
>> public class PrintDialogTestCase extends JFrame {
>> public PrintDialogTestCase() {
>>         this.setTitle("Example");
>>         this.setSize(200, 100);
>>         this.setLocationRelativeTo(null);
>>         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>> 
>>         this.setLayout(new FlowLayout());
>> 
>>         JButton printDialogButton = new JButton("Print Dialog");
>>         printDialogButton.addActionListener(new ActionListener() {
>>             public void actionPerformed(ActionEvent event) {
>>                 final PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
>>                 attributes.add(DialogTypeSelection.NATIVE);
>>                 PrinterJob printJob = PrinterJob.getPrinterJob();
>>                 if(printJob.printDialog(attributes))
>>                 {
>>                 try {
>>                 printJob.print();
>>                 } catch (PrinterException pe) {
>>                 }
>>                 }
>> 
>>             }
>>         });
>>         this.add(printDialogButton);
>> 
>>         JButton exitButton = new JButton("Exit");
>>         exitButton.addActionListener(new ActionListener() {
>>             public void actionPerformed(ActionEvent event) {
>>                 System.exit(0);
>>             }
>>         });
>>         this.add(exitButton);
>>     }
>>     public static void main(String[] args) {
>>         SwingUtilities.invokeLater(new Runnable() {
>>             @Override
>>             public void run() {
>>                 PrintDialogTestCase window = new PrintDialogTestCase();
>>                 window.setVisible(true);
>>             }
>>         });
>> 
>>     }
>> }
>> 
> 
> 
> -- 
> Best regards, Sergey.
> 



More information about the macosx-port-dev mailing list