我照书编写的mp3播放器,编译时显示 请使用 -Xlint:unchecked 重新编译,我知道问题出在哪了,要怎么改?
importjava.applet.AudioClip;importjava.awt.Container;importjava.awt.FlowLayout;import...
import java.applet.AudioClip;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComboBox;
public class J_Audio extends JApplet implements ActionListener, ItemListener
{private AudioClip m_soundFirst, m_soundSecond, m_soundCurrent;
private JButton m_buttonPlay, m_buttonLoop, m_buttonStop;
private JComboBox m_comboChoose;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
String choices [] = {"hi","bark"};//好像就是这行出问题了,我要是把这行
//注释起来,就没有这个问题了
m_comboChoose = new JComboBox(choices);
m_comboChoose.addItemListener(this);
c.add(m_comboChoose);
m_buttonLoop = new JButton("播放");
m_buttonPlay.addActionListener(this);
c.add(m_buttonPlay);
m_buttonLoop = new JButton("循环播放");
m_buttonLoop.addActionListener(this);
c.add(m_buttonLoop);
m_buttonStop = new JButton("暂停播放");
m_buttonStop.addActionListener(this);
c.add(m_buttonStop);
m_soundFirst = getAudioClip(getDocumentBase(), "hi.wmv" );
m_soundSecond = getAudioClip(getDocumentBase(), "bark.wmv" );
m_soundCurrent = m_soundFirst;
}
public void stop()
{
m_soundCurrent.stop();
}
public void itemStateChanged(ItemEvent e)
{
m_soundCurrent.stop();
m_soundCurrent=(m_comboChoose.getSelectedIndex() == 0 ?
m_soundFirst : m_soundSecond);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == m_buttonPlay)
m_soundCurrent.play();
else if (e.getSource()==m_buttonLoop)
m_soundCurrent.loop();
else if (e.getSource()==m_buttonStop)
m_soundCurrent.stop();
}
} 展开
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComboBox;
public class J_Audio extends JApplet implements ActionListener, ItemListener
{private AudioClip m_soundFirst, m_soundSecond, m_soundCurrent;
private JButton m_buttonPlay, m_buttonLoop, m_buttonStop;
private JComboBox m_comboChoose;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
String choices [] = {"hi","bark"};//好像就是这行出问题了,我要是把这行
//注释起来,就没有这个问题了
m_comboChoose = new JComboBox(choices);
m_comboChoose.addItemListener(this);
c.add(m_comboChoose);
m_buttonLoop = new JButton("播放");
m_buttonPlay.addActionListener(this);
c.add(m_buttonPlay);
m_buttonLoop = new JButton("循环播放");
m_buttonLoop.addActionListener(this);
c.add(m_buttonLoop);
m_buttonStop = new JButton("暂停播放");
m_buttonStop.addActionListener(this);
c.add(m_buttonStop);
m_soundFirst = getAudioClip(getDocumentBase(), "hi.wmv" );
m_soundSecond = getAudioClip(getDocumentBase(), "bark.wmv" );
m_soundCurrent = m_soundFirst;
}
public void stop()
{
m_soundCurrent.stop();
}
public void itemStateChanged(ItemEvent e)
{
m_soundCurrent.stop();
m_soundCurrent=(m_comboChoose.getSelectedIndex() == 0 ?
m_soundFirst : m_soundSecond);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == m_buttonPlay)
m_soundCurrent.play();
else if (e.getSource()==m_buttonLoop)
m_soundCurrent.loop();
else if (e.getSource()==m_buttonStop)
m_soundCurrent.stop();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询