public class J_Ketoo extends JApplet implements ActionListener,ItemListener
提示在“”那里出错,初步判定可能与“”有关,望高手能给我讲一下出错原因。
原代码如下:public class J_Ketoo extends JApplet implements ActionListener,ItemListener
{ File f = new File("D:\\Enterprise-SDK-Callisto-322-win32\\workspace\\J_Audio\\Audio");
File[] templefile_list=f.listFiles();//templefile_list数据中包含目录下所有文件及目录
String name[] = new String[templefile_list.length];

private JButton m_buttonPlay, m_buttonLoop, m_buttonStop;
private List myList=new List(templefile_list.length,true);


public void init()
{
Container container = getContentPane();
container.setLayout(new FlowLayout());

for(int i=0,j=0;i<=templefile_list.length;i++)//把文件名输入列表,删除非音频文件
{
name[j]=templefile_list[i].getName();
if(name[j].substring(name[j].lastIndexOf('.')+1,templefile_list.length)=="mid")
{ myList.addItem(name[j]);
j++;
}
}
myList.addItemListener( this );
container.add( myList);

m_buttonPlay = new JButton("Play");
m_buttonPlay.addActionListener( this );
container.add( m_buttonPlay );

m_buttonLoop = new JButton("Loop");
m_buttonLoop.addActionListener( this );
container.add( m_buttonLoop );

m_buttonStop = new JButton("Stop");
m_buttonStop.addActionListener( this );
container.add( m_buttonStop );
}
}

解决方案 »

  1.   

    实现方法//既然你实现这两个接口,那就把他们的方法也实现了
    public void itemStateChanged(ItemEvent e) {
        
    }
    public void actionPerformed(ActionEvent e) {
        

      

  2.   

    实现接口必须其所有方法,
    否则只能是抽象的类。
    所以应该把下面两个方法也一起实现了。 public void actionPerformed(ActionEvent e) {
    // TODO 自动生成方法存根

    } public void itemStateChanged(ItemEvent arg0) {
    // TODO 自动生成方法存根

    }