JDK-4152317 : FileDialog always shows English word "All Files (*.*) in all countries.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.2,1.1.6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.5.1,windows_95,windows_nt
  • CPU: x86,sparc
  • Submitted: 1998-06-25
  • Updated: 1999-07-20
  • Resolved: 1999-07-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.1.8 1.1.8Fixed 1.2.2Fixed
Related Reports
Duplicate :  
Description

Name: diC59631			Date: 06/25/98


Our Java-based product is being developed and tested
in 20 countries. 

It appeared that the field "Files of type" of FileDialog
always shows English string "All Files (*.*)" (in WINNT/95) 
no matter where you run the program while the rest of the components
in the FileDialog shows localized message/buttons. Noticing that
the system file dialog does show localized string of "All Files (*.*)
when we use "Open" menu of other applications, e.g, NotePad etc.

We knew the well-known bug in JDK that FilenameFilter is not working.
Thus the class FileDialog doesn't have any other method which allows
us to set the field to localized string.

Is there some magic setting which could fix the problem?
(Review ID: 34280)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.1.8 FIXED IN: 1.1.8 1.2.2 INTEGRATED IN: 1.1.8 1.2.2 VERIFIED IN: 1.1.8
14-06-2004

WORK AROUND Name: diC59631 Date: 06/25/98 None ======================================================================
11-06-2004

SUGGESTED FIX Name: rpC71689 Date: 12/19/98 prs@russia 12.19.98 Just implemented getting that message from resource bundle. awtLocalization.properties *************** *** 5,7 **** --- 5,10 ---- # Default font size for Menus and MenuItems menuFont=SansSerif-plain-11 + + # Value for "All files" for FileDialog + allFiles=All Files WFileDialogPeer.java *************** *** 17,22 **** --- 17,24 ---- import java.awt.peer.*; import sun.awt.ScreenUpdater; import java.io.FilenameFilter; + import java.util.ResourceBundle; + import java.util.MissingResourceException; public class WFileDialogPeer extends WWindowPeer implements FileDialogPeer { *************** *** 26,31 **** --- 28,36 ---- public void setFile(String file) {} public void setTitle(String title) {} + //Needed to fix 4152317 + private static native void setFilterString(String allFilter); + public void setFilenameFilter(FilenameFilter filter) { // We can set the filter, but can't do anything with it yet. System.err.println("setFilenameFilter not implemented\n"); *************** *** 73,78 **** --- 78,96 ---- ((FileDialog)target).setVisible(false); } + //This whole static block is a part of 4152317 fix + static { + try { + ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization"); + String filterString = rb.getString("allFiles"); + setFilterString(filterString); + } catch (MissingResourceException e) { + System.out.println(e.getMessage()); + System.out.println("Using non-localized message in FileDialog\n"); + setFilterString("All Files"); + } + } + // unused methods. public void beginValidate() {} public void endValidate() {} awt_FileDialog.cpp *************** *** 25,30 **** --- 25,59 ---- #include <sun_awt_windows_WFileDialogPeer.h> #include <commdlg.h> + //Localized filter string will be stored here + static char *FileFilterString = NULL; + //Non-localized suffix of the filter string + static const char AdditionalString[] = " (*.*)\0*.*\0\0"; + + //This function is a part of fix for 4152317 + void + sun_awt_windows_WFileDialogPeer_setFilterString( + Hsun_awt_windows_WFileDialogPeer *, Hjava_lang_String *filterDescription) + { + if (FileFilterString == NULL) { + int length = javaStringLength(filterDescription); + FileFilterString = new char[length * 2 + sizeof(AdditionalString)]; + //check for out of memory + if (FileFilterString == NULL) { + SignalError(0, JAVAPKG "OutOfMemoryError", 0); + return; + } + AwtFont::javaString2multibyte(filterDescription, FileFilterString, length); + char *s = FileFilterString; + //AdditionalString should be terminated by two NULL characters (Windows + //requirement), so we have to organize the following cycle and use memcpy + //unstead of, for example, strcat. + while (*s) + ++s; + memcpy(s, AdditionalString, sizeof(AdditionalString)); + } + } + void sun_awt_windows_WFileDialogPeer_show( struct Hsun_awt_windows_WFileDialogPeer *hPeer) *************** *** 59,73 **** fileBuffer[0] = '\0'; } - // No one knows what a filename filter is yet (Macs prevent just using - // extensions), so accept all files for now. - const char filter[] = "All Files (*.*)\0*.*\0\0"; - OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ! ofn.lpstrFilter = filter; ofn.nFilterIndex = 1; ofn.hwndOwner = parent ? parent->GetHWnd() : NULL; ofn.lpstrFile = fileBuffer; --- 88,98 ---- fileBuffer[0] = '\0'; } OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ! ofn.lpstrFilter = FileFilterString; ofn.nFilterIndex = 1; ofn.hwndOwner = parent ? parent->GetHWnd() : NULL; ofn.lpstrFile = fileBuffer; ======================================================================
11-06-2004

EVALUATION We hardcoded the string for the drop-down filter list into awt_FileDialog.cpp. We should get the string from a resource bundle instead. robi.khan@eng 1998-12-01 ---------------------------------------------------------------- This bug was verified as fixed via manual testing using jdk118h. al.smith@eng 1999-02-26 NOTE: The code was changed to load the string from a resource file instead of having it directly hardcoded in the program. However, a decision was made that it was too expensive to localize just this one string, so while the text is loaded at runtime, we've only provided the english version. Licensees who require the string be localized will be asked to localize the resource properties files themselves for different locales. This will not require any changes to the binary code. robi.khan@eng 1999-03-02
02-03-1999