开发者

I want to make a java program in which there is a combobox which displays the titles of all the files available in a folder

开发者 https://www.devze.com 2023-03-16 06:36 出处:网络
I actually want a JFrame in which there is a combobox. There is a folder which has 3 sound files named:

I actually want a JFrame in which there is a combobox.

There is a folder which has 3 sound files named:

The combobox should display these 3 file titles and when I click one of them it plays that sound file.


You could simply search the folder and populate the combobox with the values (Example: http://www.exampledepot.com/egs/java.io/GetFiles.html).

To play the soundfiles you may want to look here: How can I play sound in Java?


You can use .listFiles() to return the list of files in a particular folder

File someFolder = new File("pathname");

Object[] wavFiles = someFolder.listFiles(wavExtensionFilenameFilter);
JComboBox songComboBox = new JComboBox(wavFiles);

That should get you started on the UI at least, btw is this a homework question?

0

精彩评论

暂无评论...
验证码 换一张
取 消