'How can you name the component (jTextField) that shows the selected file inside a JFileChooser

I would like to give a name to every component of a jFileChooser for automation testing. Since this is a composite component, I tried to access the field with getComponent(int index) method but all the immediate components are panels. I was able to access the buttons of the jFileChooser by calling getComponent(int index) in one of the panels, but I could not find the jTextField (I assume it must be a jTextField) anywhere.

In addition, is there a better way to access the underlying components without using the getComponent(int index)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source