Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8312075

FileChooser.win32.newFolder is not updated when changing Locale

    XMLWordPrintable

Details

    • b15
    • x86_64
    • windows

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Operating System Details
      System Windows 11 Pro, build 23486.1000

      Java SE Version
      Version "20.0.1"

      A DESCRIPTION OF THE PROBLEM :
      Detailed Description of the Problem
      1) To see the result you must click above in the window, on the middle button.
      2) Entering without any identification, we can change the country, simply "New Folder" remains constant.
      3) Entering the identification "fr" we can still change the country; however the identification remains "Nouveau dossier".

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Steps to Reproduce
      Run the application in source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected Result
      The translation of "New Folder" may vary by country.
      ACTUAL -
      Actual Result
      The translation of "New Folder" always remains constant.

      ---------- BEGIN SOURCE ----------
      File "JFileChooserTest.java"
      package fileChooser;

      import java.awt.FlowLayout;
      import java.awt.event.ActionEvent;
      import java.awt.event.ItemEvent;
      import java.awt.event.ItemListener;
      import java.util.Locale;
      import java.util.ResourceBundle;

      import javax.swing.AbstractAction;
      import javax.swing.JButton;
      import javax.swing.JComboBox;
      import javax.swing.JFileChooser;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.UIManager;

      public class JFileChooserTest extends JFrame implements ItemListener {
      private static final long serialVersionUID = 1L;

      private JComboBox<String> selectedString;
      private ResourceBundle res;

      public static void main(String[] args) throws Exception {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      new JFileChooserTest(args.length == 0 ? "" : args[0]);
          }

      private void onLocaleChange(String locale) {
      res = ResourceBundle.getBundle("fileChooser.bundle", new Locale(locale));

      UIManager.put("FileChooser.acceptAllFileFilterText", res.getString("accept_all"));
      UIManager.put("FileChooser.directoryOpenButtonText", res.getString("open_text"));
      UIManager.put("FileChooser.openButtonText", res.getString("open_text"));
      UIManager.put("FileChooser.saveButtonText", res.getString("save_text"));
      UIManager.put("FileChooser.cancelButtonText", res.getString("cancel_text"));
      UIManager.put("FileChooser.lookInLabelText", res.getString("file_look"));
      UIManager.put("FileChooser.saveInLabelText", res.getString("file_save"));
      UIManager.put("FileChooser.fileNameLabelText", res.getString("file_name"));
      UIManager.put("FileChooser.filesOfTypeLabelText", res.getString("file_type"));
      UIManager.put("FileChooser.win32.newFolder", res.getString("new_folder"));
      UIManager.put("FileChooser.win32.newFolder.subsequent", res.getString("new_folder") + " ({0})");
      }

      public JFileChooserTest(String selected) {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLayout(new FlowLayout());
      onLocaleChange(selected);

      add(new JLabel("Language:"));
      add(selectedString = new JComboBox<String>(new String[] {"en", "fr"}));
      selectedString.setSelectedIndex(selected.equals("fr") ? 1 : 0);
      selectedString.addItemListener(this);

      add(new JButton(new AbstractAction("Push me to open a file chooser") {
      private static final long serialVersionUID = 1L;
      @Override
      public void actionPerformed(ActionEvent e) {
      JFileChooser chooser = new JFileChooser();
      chooser.setDialogTitle(res.getString("open_text"));
      chooser.showOpenDialog(null);
      }
      }));

      setSize(340, 240);
      setVisible(true);
      }

      @Override
      public void itemStateChanged(ItemEvent e) {
      if (e.getSource() == selectedString) {
      onLocaleChange((String)selectedString.getSelectedItem());
      }
      }
      }

      File "bundle_fr.properties"
      accept_all = Tous les fichiers
      accept_disk = Image disque
      open_text = Ouvrir
      save_text = Sauvegarder
      cancel_text = Annuler
      file_look = Regarder dans :
      file_save = Sauver dans :
      file_name = Nom du fichier :
      file_type = Type :
      new_folder = Nouveau dossier

      File "bundle.properties"
      accept_all = All Files
      accept_disk = Disk Image
      open_text = Open
      save_text = Save
      cancel_text = Cancel
      file_look = Look in:
      file_save = Save in:
      file_name = File name:
      file_type = Files of type:
      new_folder = New Folder

      ---------- END SOURCE ----------

      FREQUENCY : always

      Attachments

        1. bundle_fr.properties
          0.3 kB
          Praveen Narayanaswamy
        2. bundle.properties
          0.2 kB
          Praveen Narayanaswamy
        3. JFileChooserTest.java
          3 kB
          Praveen Narayanaswamy

        Issue Links

          Activity

            People

              tr Tejesh R
              pnarayanaswa Praveen Narayanaswamy
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: