How to make List with all files in folder using swing?

java, jlist, swing

Solution

This example shows how to enumerate the files in a directory and display them in a `JToolBar` and a `JMenu`. You can use an `Action`, such as `RecentFile`, to encapsulate behavior for use in your `ListModel` and `ListSelectionListener`.

Problem

I want to make a list with filename from a folder and show all the files that are present in that folder with a particular extension. I want the list to be selectable so that I can select and delete the file from the list or edit it. I know how to select all files from a folder but don't know how to show it in GUI. ``` File folder = new File("c:/"); File[] listOfFiles = folder.listFiles(); ```

Original source

Related problems