基于java的音乐播放器的设计(源代码+实验报告)
主类MUSICPLAYER类: import java.util.*; import javax.swing.JSlider; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectStream; import java.io.ObjectOutputStream; import java.io.Serializable; import javax.media.ControllerEvent; import javax.media.ControllerListener; import javax.media.EndOfMediaEvent; import javax.media.Manager; import javax.media.MediaLocator; import javax.media.NoPlayerException; import javax.media.Player; import javax.media.PrefetchCompleteEvent; import javax.media.Time; import javax.swing.ButtonGroup; import javax.swing.DefaultListModel; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButtonMenuItem; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.filechooser.FileNameExtensionFilter; 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:\\1.jpg“); private ImageIcon iconPre = new ImageIcon(“d:\\3.jpg“); private ImageIcon iconNext = new ImageIcon(“d:\\2.jpg“); private ImageIcon iconPause = new ImageIcon(“d:\\4.jpg“); public static void main(String[] args) { new MusicPlayer(); } public MusicPlayer() { init(); } public void init() { frame = new JFrame(); frame.setTitle(“音乐播放器“); frame.setSize(400, 300); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); menubar = new JMenuBar(); menuFile = new JMenu(“文件“); menuAbout = new JMenu(“关于“); menuMode = new JMenu(“播放模式“); itemOpen = new JMenuItem(“添加文件“);