United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7158366 [macosx] Print-to-file dialog doesn't have an entry field for a name
7158366 : [macosx] Print-to-file dialog doesn't have an entry field for a name

Details
Type:
Bug
Submit Date:
2012-04-02
Status:
Resolved
Updated Date:
2013-06-15
Project Name:
JDK
Resolved Date:
2012-06-27
Component:
client-libs
OS:
os_x
Sub-Component:
2d
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7,7u4,7u40,8
Fixed Versions:
8

Related Reports
Backport:
Backport:

Sub Tasks

Description
Mac OS X 10.7.3 macmini4,1

Try to run closed/java/awt/print/Dialog/PrintDlgApp.java test. It is broken and not runs as a jtreg test but OK as a main application.

It will show a print dialog with Print to File option selected. Click Print: you will see a file chooser dialog without an option to examine, change, or enter a filename.

                                    

Comments
mac10.8.2-x64 8b71(64bit)
sun/security/tools/policytool/i18n.sh
It has same issue,there is no filename field.
                                     
2013-01-09
mac10.8.2-x64 7u12b05(64bit)
sun/security/tools/policytool/i18n.sh 
It has same issue: there is no filename field.refer to i18n.jpg
                                     
2013-01-08
EVALUATION

I like setting the SAVE_DIALOG type in the printing code,
since printing to file always needs the file name
                                     
2012-04-10
EVALUATION

I think I see the problem. 
JFileChooser defaults to being an "Open" dialog. Printing needs
to use it as a "Save" dialog so you can create the new file.

Metal and I guess Windows L&F always show the editable file name field,
so its not mattered. Aqua seems to be quite different in this regard.
I can fix it in printing code by adding

jfc.setDialogType(JFileChooser.SAVE_DIALOG); 

I don't think this will cause any new problems.

I do not have a definite explanation why this was not a problem in
Apple JDK6 other than to speculate that since this afflicted Apple
users that it was fixed in ServiceDialog.java there but never
made it back to us or into the JDK 7 OS X port code ???
                                     
2012-04-09
EVALUATION

I assigned it back to get more information from the 2d side:

How does the test case provided in the previous post 
connect with the desribed bug?

The FC test hangs on my machine when I run it,
however if I wrap it with Runnable and invoke it on EDT
the dialog is shown as expected.

import javax.swing.*;
import java.io.*;

public class FC {
    public static void main(String args[]) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFileChooser jfc = new JFileChooser();
                jfc.setSelectedFile(new File("foo.txt"));
                jfc.setApproveButtonText("Print");
                jfc.setDialogTitle("Print to file");
                jfc.showDialog(null, null);
            }
        });
    }
}

The sun.print.ServiceDialog seems to be driven by the various settings
so it is not clear if this is a Swing problem

Feel free to reassign it back
                                     
2012-04-09
EVALUATION

This seems to be a generic problem with the Swing file chooser likely specific to Aqua.
Printing just happens to use that dialog/chooser.
It does seem to be a regression as it was OK with JDK6

Just run this program :

import java.io.*;
import javax.swing.*;

public class FC {
  public static void main(String args[]) {
    JFileChooser jfc = new JFileChooser();
    jfc.setSelectedFile(new File("foo.txt"));
    jfc.setApproveButtonText("Print");
    jfc.setDialogTitle("Print to file");
    jfc.showDialog(null, null);
 }
}
                                     
2012-04-05



Hardware and Software, Engineered to Work Together