基于java的音乐播放器的设计源代码+实验报告

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

主类M U S I C P L A Y E R类:import .*;

public class MusicPlayer implements ActionListener, Serializable,ControllerListener {

private static final long serialVersionUID = 1L;

private JFrame frame = null;

private JPanel controlPanel = null;

private JButton btnPlay = null;

private JButton btnPre = null;

private JButton btnNext = null;

private JScrollPane listPane = null;

private JList list = null;

private DefaultListModel listModel = null;

private JMenuBar menubar = null;

private JMenu menuFile = null, menuAbout = null, menuMode = null;

private JMenuItem itemOpen, itemOpens, itemExit, itemAbout;

private JRadioButtonMenuItem itemSingle, itemSequence ,itemRandom;

private ListItem currentItem = null;

private static Player player = null;

private boolean isPause = false;

private int mode;

private int currentIndex;

private ImageIcon iconPlay = new ImageIcon("d:\\");

private ImageIcon iconPre = new ImageIcon("d:\\");

private ImageIcon iconNext = new ImageIcon("d:\\");

private ImageIcon iconPause = new ImageIcon("d:\\");

public static void main(String[] args)

{

new MusicPlayer();

}

public MusicPlayer()

{

init();

}

public void init()

{

frame = new JFrame();

("音乐播放器");

(400, 300);

(false);

(null);

;

menubar = new JMenuBar();

menuFile = new JMenu("文件");

menuAbout = new JMenu("关于");

menuMode = new JMenu("播放模式");

itemOpen = new JMenuItem("添加文件");

itemOpens = new JMenuItem("添加文件夹");

itemExit = new JMenuItem("退出");

itemAbout = new JMenuItem("关于");

(this);

(this);

(this);

(this);

itemSequence = new JRadioButtonMenuItem("顺序播放"); (true);

itemSingle = new JRadioButtonMenuItem("单曲循环"); (this);

itemRandom = new JRadioButtonMenuItem("随机播放"); (this);

(this);

ButtonGroup bg = new ButtonGroup(); (itemRandom);

(itemSequence);

(itemSingle);

(itemOpen);

(itemOpens);

(itemExit);

(itemAbout);

(itemSequence);

(itemSingle);

(itemRandom);

(menuFile);

(menuAbout);

(menuMode);

(menubar);

(new BorderLayout());

controlPanel = new JPanel();

(new FlowLayout());

btnPlay = new JButton(iconPlay);

btnPre = new JButton(iconPre);

btnNext = new JButton(iconNext);

(this);

(this);

(this);

(btnPre);

(btnPlay);

(btnNext);

listPane = new JScrollPane();

listModel = load();

list = new JList(listModel);

if () == -1 && () > 0)

{

currentItem = (ListItem) (0);

(0);

currentIndex=0;

}

().add(list);

(new MouseAdapter()

{

public void mouseClicked(MouseEvent e)

{

if () == 2)

{

if(player!=null)

{

();

(iconPlay);

}

currentIndex = ());

currentItem = (ListItem) (currentIndex);

(currentIndex);

play();

}

}

});

(new BorderLayout());

(controlPanel, ;

(listPane, ;

(true);

};

public void actionPerformed(ActionEvent e)

{

if () == itemOpen)

{oLowerCase().endsWith(".mp3")|| ().toLowerCase().endsWith(".wav"))

return true;

return false;

}

});

for (File file : files)

{

ListItem item = new ListItem(), ());

相关文档
最新文档