< prev index next >

src/org/netbeans/jemmy/operators/JFileChooserOperator.java

Print this page

        

@@ -41,10 +41,11 @@
 import javax.swing.JList;
 import javax.swing.JTable;
 import javax.swing.JTextField;
 import javax.swing.JToggleButton;
 import javax.swing.ListModel;
+import javax.swing.UIManager;
 import javax.swing.filechooser.FileFilter;
 import javax.swing.filechooser.FileSystemView;
 import javax.swing.filechooser.FileView;
 import javax.swing.plaf.FileChooserUI;
 import javax.swing.table.TableModel;

@@ -339,22 +340,22 @@
      * Returns either a JList or JTable, depending on the implementation.
      *
      * @return a component being used to display directory content.
      */
     public Component getFileList() {
-        int index = 0;
-        // In GTK and Motif L&F, there are two JLists, one is to list folders
-        // and second one one is to list files
+        final String fileListName;
         if (LookAndFeel.isMotif() || LookAndFeel.isGTK()) {
-            index =1;
+            fileListName = UIManager.getString("FileChooser.filesLabelText", getLocale());
+        } else {
+            fileListName = UIManager.getString("FileChooser.filesListAccessibleName", getLocale());
         }
         return innerSearcher.
                 findComponent(new ComponentChooser() {
                     @Override
                     public boolean checkComponent(Component comp) {
-                        return (comp != null
-                                && (comp instanceof JList || comp instanceof JTable));
+                        return ((comp instanceof JList && fileListName.equals(comp.getAccessibleContext().getAccessibleName()))
+                                || comp instanceof JTable);
                     }
 
                     @Override
                     public String getDescription() {
                         return "JList or JTable used to show list of files";

@@ -362,11 +363,11 @@
 
                     @Override
                     public String toString() {
                         return "JFileChooserOperator.getFileList.ComponentChooser{description = " + getDescription() + '}';
                     }
-                }, index);
+                });
     }
 
     /**
      * Pushes approve button.
      */
< prev index next >