JFileChooser UIManager keys (I18n)

Hello everybody,
for a multi-language application I need to change the filechooser texts at runtime.
This can be done e.g. with
UIManager.put("FileChooser.cancelButtonText", myNewCancelTxt);Most of the keys like "FileChooser.cancelButtonText" can be found in the source files BasicFileChooserUI.java and MetalFilechooserUI.java. But not all. Where is for example "FileChooser.fileNameHeaderText" hidden, and what are the key names of the items of the menu popping up at a RMB click (they offer "View" and "Refresh")?
I have been looking for a properties file where all these keys are given, but didn't find one.
Regards
J�rg

But not all. Where is for example
"FileChooser.fileNameHeaderText" hidden, and what are
the key names of the items of the menu popping up at
a RMB click (they offer "View" and "Refresh")?
I have been looking for a properties file where all
these keys are given, but didn't find one.
Searching through the source code for "fileNameHeaderText" I found a bunch of resource files in the com.sun.java.swing.plaf.windows.resources package ("windows.java", "windows_de.java", etc) that seems to define some constants for the filechooser UI. Maybe that is what you are looking for?

Similar Messages

  • Help with "simple" JFileChooser problem...

    Hi all,
    how do I set the font in a JFileChooser???
    I have tried everything, but it always uses the Look & Feels default font setting. Can I change the default Look&Feels font setting?
    Greatfully for any suggestions!
    Cheers
    Anders ;-D

    Hello!
    You can use the UIManager, e.g. UIManager.put("FileChooser.font", new Font("Arial",
    Font.BOLD, 14);
    Well, that didn't seem to help with my case either. So I tried something else: I overrided all of the defaults by using UIManager.put(key, value) this way I got all of the Fonts in the JFileChooser to change.
    Correct me if I'm wrong... ;)
    - Cathra -
    Sample Code that performs the requested:
    // Prepare the resources
    FontUIResource font12Arial = new FontUIResource( "Arial", Font.PLAIN, 12 );
    // Put values into UIDefaults (before initializing the JFileChooser)
    UIManager.put( "ToolTip.font", font12Arial );
    UIManager.put( "OptionPane.messageFont", font12Arial );
    // shown for example
    UIManager.put("FileChooser.openButtonText", "OpenUp");
    UIManager.put("Button.font", font12Arial);
    UIManager.put("Label.font", font12Arial);
    UIManager.put("Table.font", font12Arial);
    UIManager.put("TextField.font", font12Arial);
    UIManager.put("ScrollPane.font", font12Arial);
    UIManager.put("ComboBox.font", font12Arial);
    UIManager.put("CheckBox.font", font12Arial);
    UIManager.put("TitledBorder.font", font12Arial);
    UIManager.put("RadioButton.font", font12Arial);
    UIManager.put("ToolTip.font", font12Arial);
    UIManager.put("TextPane.font", font12Arial);
    UIManager.put("TextArea.font", font12Arial);
    UIManager.put("Tree.font", font12Arial);
    UIManager.put("List.font", font12Arial);
    UIManager.put("MenuBar.font", font12Arial);
    UIManager.put("Menu.font", font12Arial);
    UIManager.put("MenuItem.font", font12Arial);
    UIManager.put("TableHeader.font", font12Arial);
    UIManager.put("TabbedPane.font", font12Arial);
    // somewhere in the code:
    JFileChooser c = new JFileChooser();
    c.showOpenDialog(aParentFrame);

  • JRE1.6 in Windows Vista for Swing based application

    Hi,
    I am running a Swing based and applet based application in Windows VISTA using JRE 1.6_U13. The text font is appearing bold in JRE 1.6_U13 whereas it is appearing normal while using JRE 1.5, though the style of the Font
    is "SansSerif", PLAIN and size 12 for both JRE 1.6 and JRE 1.5.
    Reason for the Issue:
    Swings follows the concept of taking the display values from the Windows UIManager(). The UIManager consists of keys and values. The values for the keys change from OS to OS. As a result, if the UIManager key values are not overridden with the customized values, the display will change from OS to OS. Hence the issue has occurred.
    Analysis:
    Case-1:
    1.     CALM is setting the font style to “Font("SansSerif", Font.PLAIN, 12)”.
    2.     This font is being set to the Label and Text components in swings.
    3.     The font class consists of Font.PLAIN argument whose value is 0 as per the java API.
    4.     This value can’t be changed.
    5.     Hence we couldn’t solve.
    Case-2:
    1.     We tried to get the key value for the key “Label.font” and tried to override its value.
    2.     But then the issue is with the Font.Plain which is one of the arguments in Font object.
    3.     Hence couldn’t achieve it.
    Case-3:
    1.     We thought of creating a new font where in we can have control over the weight and width of the text. Then set this font to respective key of the UIManager.
    2.     Here the weight indicates the bold thickness. As a result of which we thought of changing the weight.
    3.     But then the options that we have in the API are less and the least weight value is “TextAttribute.WEIGHT_EXTRA_LIGHT” which is equal to “0.5”.
    4.     This value is not sufficient as the boldness of the text is comparatively more than the text that is appearing in jre-1.5.
    5.     Then we tried to give the value manually, instead of using the API. But then, it was mentioned in the API that any values mentioned other than the ones specified in the API will be rounded to the nearest integer.
    6.     By doing this we have customized the boldness of the Label, but could not achieve the required boldness of the Label.
    Please need a urgent solution.

    Hi,
    The reason of the problem is Antialiasing effect of the graphics. In Control Panel -> Performance Information and tools -> Adjust visual effect, if the 'Smooth edges of screen font' is unchecked then the boldiness of the font or the Antialiasing effect is not there.
    But this effect is reflecting not only on my swing based and applet based application but also on the whole system.
    I tried to call the renderingHint method and change default value of the key KEY_TEXT_ANTIALIASING to VALUE_TEXT_ANTIALIASING_OFF, to make the antialiasing effect off for the application.
    I implemented the below code:
    Graphics g= new Graphics();
    Graphics2D g2d = (Graphics2D)g;
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
    RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    But I am not able to create an object of Graphics.

  • Changing tick colour on JSliders. any clues?

    Hi there,
    Is there a way to change the colour of the tick labels or colours on a JSlider?
    Cheers,
    Hugh

    Sorry, I thought you were referring to just the basic JLabel. But wait a minute -- the slider labels are JLabels:
    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    public class SliderTest {
        public static void main(String[] args) {
            JSlider s = new JSlider();
            s.setMajorTickSpacing(10);
            s.setPaintTicks(true);
            s.setPaintLabels(true);
            Random rnd = new Random();
            Dictionary labs = s.getLabelTable();
            for (Enumeration keys = labs.keys(); keys.hasMoreElements(); ) {
                Color clr = new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
                Object key = keys.nextElement();
                ((Component) labs.get(key)).setForeground(clr);
            JFrame f = new JFrame("SliderTest");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(s);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }By the way, I have poked around in the source code for javax.swing.plaf.basic.basicSliderUI, like its
    paintLabels method, and no joy -- there doesn't seem to be a UIManager key involved.

  • New oreilly book on swing

    its about time! anyone looking foward to this ?
    http://www.amazon.com/exec/obidos/ASIN/0596004087/qid=1036172829/sr=2-1/ref=sr_2_1/002-8059781-3585653

    I've been using the Robinson book and I find it to be excellent. The O'Reilly book is also good, though I'm not as familiar with it as I am with the Robinson book.
    The O'Reilly book does have a section on the UIManager keys, which I haven't seen elsewhere.
    The Robinson book has the best coverage on printing that I've seen.

  • Book on Swing

    I am looking to buy a good book focusing on Swing. Any suggestions? One that I am looking at is "Swing, Second Edition" by Matthew Robinson, Pavel Vorobiev. Is this one any good or are there better ones?

    I've been using the Robinson book and I find it to be excellent. The O'Reilly book is also good, though I'm not as familiar with it as I am with the Robinson book.
    The O'Reilly book does have a section on the UIManager keys, which I haven't seen elsewhere.
    The Robinson book has the best coverage on printing that I've seen.

  • JOptionPane desn't update the locale  settings.

    Hi, when I use Locale.setDefault the JOptionPane still uses the system defaults for OK, Cancel and so on.
    What is wrong?
    Any help is welcome.
    Greetings Michael

    The default button options for JOptionPanes are all hardcoded, as are many other little bits of text like tool tips for default components (window close/maximize/minimize buttons etc) in Swing. You need to set the text for these components manually using the UIManager, it's slow and ugly but AFAIK it's the only way to do it. So if you wanted to change the "Yes" button, to "Oui" (French locale) then you could do this...
    UIManager.put("OptionPane.yesButtonText", "Oui"); The UIManager keys you need are sadly not (to my knowledge) documented anywhere, which means you have to rely on people here having found them already, or trauling through the source code for the component in question trying to find them yourself.
    Hope this helps,
    Tom

  • How to close JFileChooser dialog only while using ESC key ?

    Hi All,
    I am using a Frame and from this frame i am calling the JFileChooser via a JButton.
    and using JFileChooser ShowOpenDialog() for open and close .
    while doing ESC operation my Main Frame is getting closed with JFileChooser dialog.
    Can i close only JFileChooser dialog while doing ESCAPE key operation.
    I Have Escape key function in Main Frame file and JFileChooser file( EscKeyEventActionIntialization)
    But while debuging i am not able to catch the esc key action inside EscKeyEventActionIntialization.
    I have attached the code, please suggest me , if i need to do any change .
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package MainPackage;
    import javax.swing.filechooser.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.*;
    public class SourceSettings extends javax.swing.JDialog{
        JDialog dialog;
        private javax.swing.JFileChooser jFileChooser1;
        MainFile  mainFile;
        ImageIcon icon = new ImageIcon(getClass().getResource("/Resource/mchpIcon.GIF"));
        /** Creates new form SourceSetting */
        public SourceSettings(MainFile  pMPFS) {
            dialog = new JDialog();
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            mainFile = pMPFS;
            jFileChooser1 = new javax.swing.JFileChooser();
            dialog.add(jFileChooser1);
            EscKeyEventActionIntialization();
            jFileChooser1.setDialogTitle("Browse For Folder");
            jFileChooser1.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 11)); // NOI18N
            jFileChooser1.setName("Browse For Folder"); // NOI18N
        public String getDirctoryPath()
            int retval = jFileChooser1.showOpenDialog(dialog);
            dialog.setVisible(true);
            if(retval  == JFileChooser.APPROVE_OPTION)
                return jFileChooser1.getSelectedFile().getAbsolutePath().toString();
            else
                dialog.setVisible(false);
                dialog.dispose();
                return null;
        public String getParentDirctoryPath()
            return jFileChooser1.getCurrentDirectory().getAbsolutePath().toString();
        public String getOutputDirctoryPath()
            if(jFileChooser1.showOpenDialog(mainMpfs)  == JFileChooser.APPROVE_OPTION)
               return jFileChooser1.getCurrentDirectory().getAbsolutePath().toString();
            else
               dialog.dispose();
               return null;
        private void EscKeyEventActionIntialization()
            Action  ESCactionListener = new AbstractAction () {
              public void actionPerformed(ActionEvent actionEvent) {
                dialog.setVisible(false);
                dialog.dispose();
            KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true);
            JComponent comp = dialog.getRootPane();
            comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "ESCAPE");
            ActionMap actionMap = comp.getActionMap();
            actionMap.put("ESCAPE", ESCactionListener);
    }

    You have a class that extends JDialog and has a JDialog member variable (very confusing), and no main(...) method. How is the class used as a JDialog?
    To get better help sooner, post a SSCCE that clearly demonstrates your problem. Note that this should be executable and should not contain any extraneous code.
    db

  • Problem with Tab Key in JFileChooser when Details view is selected.

    Hi all,
    Iam using a JFileChooser in my application.When i click Details option in the JFileChooser the files with the size,Type and modified date are displayed.
    When i am using tab to navigate through the JFileChooser,when the tab enters the area where the files are listed with details,the tab is not comming out of the File List area,instead it is traversing with in the files.How do i come out of the File List area using Tab key.I wanted to make a functionality similar to Windows FileChooser where in if we press Tab it goes to the file list and the next tab focus to Text field and so on.
    Is it possible using JFileChooser??
    Pls Help me,
    Thanks and Regards,
    Ravi

    Hi,
    looking at other threads, I think you will
    have to get the button and modify/remove the tool tip
    as you which.
    this thread might help you, at least the way to get the components in the file
    chooser:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=563002

  • How to put a javascript  variable containg the i18n key  in the i18n tag

    I have a list of values in a List box.when the user selects a praticular value.,i need to show the java script localized alert message for the selected value.
    how can i pass the javascript variable to i18n tag.
    For ex:
    function test(){
    var selectedvalue='name';
    var localizedstring='<i18n:message key="+selectedvalue+"/>';--This is not working
    alert('<i18n:message key="+selectedvalue+"/>');
    the alert message is a blank string,even though i have the key in my resource bundle.
    Also..if i give directly pass the key value to i18n string it works. like..
    var localizedstring='<i18n:message key="+name+"/>';--This is  working
    *(am passing the variable value)*

    The following should be able to pass ans.
    <script language="Javascript">
    function check_answer(ans) {
    if (testing.result.value==ans ){
    window.alert("You have got 10 marks.");
    </script>
    <body>
    <form name="testing"...>
    <%
    ResultSet rs = stmt.executeQuery("select * from level where...");
    while(rs.next())
    out.println("<tr>");
    out.println("<td>" + rs.getString("question") + "</td>");
    ans = rs.getString("answer");
    out.println("</tr>");
    out.println("<input type='text' name='result'>);
    out.println("<input type='button' value='Enter' onclick='check_answer('<%= ans%>')'>");
    %>jag

  • JFileChooser - activating buttons with the enter key

    Hi All,
    I am trying to figure out how to activate the cancel button in the file chooser by tabbing to it, and than pressing the enter key. I know how to do this in a regular dialog, but I can't seem to get the access I need to the JFileChooser to get it to work there.
    I would appreciate any help.
    Thanks!
    robinste

    The Buttons in the File Chooser by default dont use the Enter Key.
    You must make the Enter key work if you are to use it
    after you tab to get the focus on to it.
    For this to be done you will need to extend the FileChooser
    and change the key listener for the cancel button .......
    Hope t was of some help ............

  • JFileChooser Multiple selection not working on Mac using apple, command key

    I am using Java 1.4 webstart on Mac machine.
    The code is :
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(2);
    fileChooser.setMultiSelectionEnabled(true);
    Once the File dialog opens I have problems in selecting random multiple files. Apple key or command key is used for random selection on Mac. When using either of these keys multiple selection is not possible. Whereas I am able to select files using the shift key by which row selection is possible.
    If this is not a bug and some code changes are to be done it would be fine if somebody can help me out in this.
    If this is a bug in Java 1.4 and is this fixed in Java 1.5?

    All EIDE / ATA (Parallel) devices (drives, opticals) allowed for two such drives or devices on one bus. The old style was "master" and "Slave" but CS is a "smart" approach, however, the master or only device must be on the end position. Also, the end connector will be black, the middle (slave) is gray.
    Eject sends signal to master
    To eject the "slave" device you use a modifier key.

  • JFileChooser Multiple selection not working on Mac using apple key

    I am using Java 1.4 webstart on Mac machine.
    The code is :
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(2);
    fileChooser.setMultiSelectionEnabled(true);
    Once the File dialog opens I have problems in selecting random multiple files. Apple key is used for random selection on Mac. When using the apple key multiple selection is not possible. Whereas I am able to select files using the command key by which row selection is possible.
    If this is not a bug and some code changes are to be done it would be fine if somebody can help me out in this.
    If this is a bug in Java 1.4 and is this fixed in Java 1.5?

    All EIDE / ATA (Parallel) devices (drives, opticals) allowed for two such drives or devices on one bus. The old style was "master" and "Slave" but CS is a "smart" approach, however, the master or only device must be on the end position. Also, the end connector will be black, the middle (slave) is gray.
    Eject sends signal to master
    To eject the "slave" device you use a modifier key.

  • Unrecognized I18N key:

    I tried out the Sun Update Connection web interface. Seems neat, but I'm get the following error message for every patch I try to install this way:
    Unrecognized I18N key: "swup.server.smpatch.". Please contact Sun Support for comment explanation
    I installed patch 122231-01 before I attempted this.
    Can anyone explain what this means? I tried to contact Sun through the online support center, but all I get is "Read timed out" errors while attempting to fill out the forms. Can't seem to locate an email address for support.
    Many thanx

    Hello,
    There has been a bug raised for the error which you are seeing 6314844. The URL for this is below:
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=6314844&site=sunsolve&otf=ss&col=support-sunsolve&otf=sunsolve&site=ss&col=search-sunsolve
    Is this the only error which you are seeing?
    Regards

  • Localizing JFileChooser (Without using UIManager)

    Hello,
    I need to localize JFileChooser (in French and German) and my application is only targeted to run on JRE 1.6+.
    I read the following (at [http://www.rgagnon.com/javadetails/java-0299.html] ):
    Modern Swing release have now built-in ready-to-use translations for the JFileChooser.
    The language is choosen based on the current Locale. So you don't have to do anything to
    display the JFileChooser in the right language.And I also got to know from the sun java swing forum
    ( at [http://forums.sun.com/thread.jspa?forumID=57&threadID=5121485] ) that :
    The JFileChooser naturally is localized. You just need to ensure you have the internationalized jre.
    If you mean to say you are running on an english OS and want it to display russian, then
    it is a little more work.You could try calling
    Locale.setDefault(<appropriate locale>);
    The jre also may use the native file chooser, which makes things harder, in this case
    the setting of the locale may not work.But no matter what I do I am not able to localize the JFileChooser.
    Can any body tell me the correct procedure of doing this
    (Well I know about the workaround i.e. doing it using the UIManager).
    TIA and Regards,
    Vivek

    Yes it works, Thanks a ton Darryl.Burke .
    What you said is: You can also set the default locale on a per-class basis *before creating the instance* of the class and this works :-
    //Works:
    JFileChooser.setDefaultLocale(Locale.ITALIAN);
    JFileChooser chooser = new JFileChooser();
    chooser.showOpenDialog(null);But the below one dosen't (The one which I tried). Why ?
    // Doesn't work
    Locale.setDefault(Locale.ITALIAN);
    JFileChooser chooser = new JFileChooser();
    chooser.setLocale(Locale.ITALIAN);
    chooser.showOpenDialog(null);*What is the difference between non-static method setLocale() and the static method setDefaultLocale() ?*
    Thanks again Darryl.Burke
    Vivek

Maybe you are looking for