How to create a folder browser in java swing?

2

I want to create a window and it has a button, when the user clicks that button, that "windows folder browser" will appear for the user to select a folder of his machine and the address of the folder is saved in a variable. It is possible? I do not know how to open this "folder browser".

    
asked by anonymous 18.11.2017 / 00:56

1 answer

1

There is a component called JFileChooser that enables selection of file system files, through a window that opens, returned the path of that file, as can be seen in the image below:

[

JTree can also be used for navigation, although the appearance is somewhat strange and probably does not return anything like the previously mentioned component. It looks like this:

[

For most needs in applications that need to access the current file system, the two components usually serve well, for something more specific and custom, then you need to study the API and create it on its own or customize the JFileChooser .

    
18.11.2017 / 01:04