使用Swing Gui制作音乐列表



我正在使用Java Swing创建音乐播放器。在我想制定的程序中,我已经选择了一个播放列表。我想通过列表在GUI中展示音乐。我想选择该GUI列表并播放音乐。我认为我可以使用forwhile列出列表,但我没有任何想法。如何在GUI上列出音乐列表?

您可以使用combobox(下拉菜单)。

示例(来自链接):

String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
//Create the combo box, select item at index 4.
//Indices start at 0, so 4 specifies the pig.
JComboBox petList = new JComboBox(petStrings);
petList.setSelectedIndex(4);
petList.addActionListener(this);

您也可以使用jbuttons,以及布局管理器。

最新更新