How to create a folder browser in java swing?

Asked

Viewed 411 times

2

I want to create a window and it has a button, when the user clicks that button appears that "typical windows folder browser" for the user to select a folder from his machine and the folder address is saved in a variable. Is that possible? I don’t know how to open this "folder browser".

1 answer

1


There’s a component called Jfilechooser which enables file selection of the file system, through a window that opens, returned the path of that file, as can be seen in the image below:

[inserir a descrição da imagem aqui]

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

[inserir a descrição da imagem aqui]

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.