-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
generic
-
generic
I am trying to print a frame to a file through AWT printing APIs. I am specifying the destination type as File, dialog type as None and an empty string as the file name. The application works fine without throwing any exception but no file is created.
When the file name is an empty string or a string with whitespaces, the default file name is not getting used. This is acceptable when the user pops a dialog. Once the dialog is popped up, it mandates the user to enter a file name to come out of the dialog. But in case of NONE dialog, there is no clue where the file is getting created or in fact whether it is getting created at all. The printing system must validate the file name properly in case of NONE dialog and throw exceptions accordingly or must use the default file name in the above scenarios. If the file name is null, it is handled properly where the default file name is getting used. This must be implemented for other scenarios also where the file name could be an empty string or with white spaces.
This is reproducible on Win32 as well as Solaris right from JDK1.4. I tested this on Win XP and Solaris 8.
I have attached a sample test. Execute the sample test. Enter some white spaces in the text field. Choose NONE dialog option. Click the print button. There will not be any error or exception and also no file will be created.
It would be better even in case of NATIVE/COMMON dialog to default the file dialog with the default file name if the specified file name is invalid.
When the file name is an empty string or a string with whitespaces, the default file name is not getting used. This is acceptable when the user pops a dialog. Once the dialog is popped up, it mandates the user to enter a file name to come out of the dialog. But in case of NONE dialog, there is no clue where the file is getting created or in fact whether it is getting created at all. The printing system must validate the file name properly in case of NONE dialog and throw exceptions accordingly or must use the default file name in the above scenarios. If the file name is null, it is handled properly where the default file name is getting used. This must be implemented for other scenarios also where the file name could be an empty string or with white spaces.
This is reproducible on Win32 as well as Solaris right from JDK1.4. I tested this on Win XP and Solaris 8.
I have attached a sample test. Execute the sample test. Enter some white spaces in the text field. Choose NONE dialog option. Click the print button. There will not be any error or exception and also no file will be created.
It would be better even in case of NATIVE/COMMON dialog to default the file dialog with the default file name if the specified file name is invalid.
- duplicates
-
JDK-4973278 Printing to File throws NPE on Sol when the given file name represents a dir
-
- Closed
-