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 );
}
}
提示在“”那里出错,初步判定可能与“”有关,望高手能给我讲一下出错原因。
原代码如下: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 );
}
}
public void itemStateChanged(ItemEvent e) {
}
public void actionPerformed(ActionEvent e) {
}
否则只能是抽象的类。
所以应该把下面两个方法也一起实现了。 public void actionPerformed(ActionEvent e) {
// TODO 自动生成方法存根
} public void itemStateChanged(ItemEvent arg0) {
// TODO 自动生成方法存根
}