开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜