2016-11-23 66 views
-1

我使用Java Swing創建音樂播放器。在我想製作的節目中,我已經選擇了一個播放列表。我想通過列表顯示gui中的音樂。我想選擇那個gui列表並播放音樂。我認爲我可以使用forwhile來製作清單,但我沒有任何想法。 如何在GUI上製作音樂列表?使用Swing GUI製作音樂列表

+0

您可以使用像JList或JTextArea這樣的組件來使用文本/圖標來顯示它們。 – Logan

回答

1

您可以使用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); 

你也可以使用Jbutton將與佈局管理器一起。