Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2005

Tip: Looking for answers? Try searching our database.

JFileChooser Localization

Thread view: 
Jim Cobban - 10 Jan 2005 21:45 GMT
I have been able to localize every string in the JFileChooser except the
tooltip on the "Desktop" icon.  This continues to come out as "Desktop"
regardless of the Locale I specify.  Does anyone know if there is a resource
that can be used to customize this string to the Locale?
John McGrath - 11 Jan 2005 02:08 GMT
> I have been able to localize every string in the JFileChooser except the
> tooltip on the "Desktop" icon.  This continues to come out as "Desktop"
> regardless of the Locale I specify.  Does anyone know if there is a
> resource that can be used to customize this string to the Locale?

Did you take a look at the source code?  A quick search comes up with code
in both the Windows and Metal FileChooserUI classes that looks like:

  toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".

So it looks like it is displaying the name of the actual desktop folder.
Have you tried renaming that to see if it changes the tooltip.

Signature

Regards,

John McGrath

Jim Cobban - 11 Jan 2005 15:26 GMT
Thank you for finding that code for me.

I tried going into Explorer and changing the name of the Desktop, but I get
a message "Cannot rename file. File system error (1026)"

> > I have been able to localize every string in the JFileChooser except the
> > tooltip on the "Desktop" icon.  This continues to come out as "Desktop"
[quoted text clipped - 8 lines]
> So it looks like it is displaying the name of the actual desktop folder.
> Have you tried renaming that to see if it changes the tooltip.
John McGrath - 11 Jan 2005 23:32 GMT
> I tried going into Explorer and changing the name of the Desktop,
> but I get a message "Cannot rename file. File system error (1026)"

I just renamed it on my system without any problems.  I just found the
actual folder and renamed it using Windows Explorer.  As I recall, the
folder is normally under "Documents and Settings/<username>", although
I have it in a different location on my system.  The error you got may be
because you are using a different operating system - I am using Window
XP Pro.

I ran the SwingSet JFileChooser example, and the tooltip for the Desktop
button showed the new name.  So my guess is that you really do not have to
worry about this.  The folder name probably varies by locale and the name
should make sense for that locale.

If you really need to change the tooltip, you should be able to accomplish
that.  The tooltip is set by the UI when it is installed, so you could add
a property listener to the JFileChooser for the "UI" property and change
it then by hunting down the button in the component hierarchy and setting
it using setTooltipText().

Obviously, this kind of approach is dependent on the UI and can be
somewhat fragile, but if you use a conservative approach, you should be
able to make it work in almost all cases and "do no harm" in others.

Signature

Regards,

John McGrath

Jim Cobban - 12 Jan 2005 16:59 GMT
Thank you for going out of your way to help me.  I am still running Win98
which may explain a lot of my problems.  For example, although nobody else
can reproduce this behavior, I cannot get JFileChooser to show the correct
file icons for Windows.  I have had to override FileSystemView to supply my
own icons for the file types that my application supports.  I attempted to
change the name of the desktop folder not in its real location in the
hierarchy but rather in the spot where it appears when you first enter
Explorer.  Your test reassures me that the button will have an appropriate
name on any system that it is run on.  I assume that the Windows
installation process names various folders, including Desktop, in a manner
appropriate to the locale specified when the system was installed.

> > I tried going into Explorer and changing the name of the Desktop,
> > but I get a message "Cannot rename file. File system error (1026)"
[quoted text clipped - 20 lines]
> somewhat fragile, but if you use a conservative approach, you should be
> able to make it work in almost all cases and "do no harm" in others.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.