--- old/src/org/netbeans/jemmy/operators/JFileChooserOperator.java 2018-10-23 22:55:16.219735376 -0700 +++ new/src/org/netbeans/jemmy/operators/JFileChooserOperator.java 2018-10-23 22:55:16.145734296 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,7 @@ 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; @@ -340,6 +341,13 @@ * @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 + if (UIManager.getLookAndFeel().getID().equals("Motif") + || UIManager.getLookAndFeel().getID().equals("GTK")) { + index =1; + } return innerSearcher. findComponent(new ComponentChooser() { @Override @@ -357,7 +365,7 @@ public String toString() { return "JFileChooserOperator.getFileList.ComponentChooser{description = " + getDescription() + '}'; } - }); + }, index); } /** @@ -433,7 +441,15 @@ getQueueTool().waitEmpty(); output.printTrace("Go home in JFileChooser\n : " + toStringSource()); - JButtonOperator homeOper = new JButtonOperator(getHomeButton()); + AbstractButtonOperator homeOper; + // In Windows and Windows Classic L&F, there is no 'Go Home' button, + // but there is a toggle button to go desktop. In Windows platform + // 'Go Home' button usually navigates to Desktop only. + if(UIManager.getLookAndFeel().getID().equals("Windows")) { + homeOper =new JToggleButtonOperator(this, 1); + } else { + homeOper = new JButtonOperator(getHomeButton()); + } homeOper.copyEnvironment(this); homeOper.setOutput(output.createErrorOutput()); homeOper.push();