代码哪里错,没结果
import javax.swing.*;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Buttonlcon extends JPanel implements ActionListener{
public static void main(String[]args)
{
JFrame jf=new JFrame();
Buttonlcon bi=new Buttonlcon();
jf.getContentPane().add(bi);
jf.setSize(400,300);
jf.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);}
});
}
public Buttonlcon (){
super();
button = new JButton[3];
imagelcon = new ImageIcon[3];
imagelcon[0]= new ImageIcon("inages\\first.gif");
imagelcon[1]= new ImageIcon("inages\\second.gif");
imagelcon[2]= new ImageIcon("inages\\third.gif");
button[0]=new JButton(imagelcon[0]);
button[1]=new JButton(imagelcon[1]);
button[2]=new JButton(imagelcon[2]);
add(button[0]);
add(button[1]);
add(button[2]);
button[0].addActionListener(this);
button[1].addActionListener(this);
button[2].addActionListener(this);
}
public void actionPerformed(ActionEvent e){
ImageIcon imageMcon;
if((JButton)e.getSource()== button[0]){
for (int i=0; i<3;i++);
imageMcon= imagelcon[0];
imagelcon[0]= imagelcon[1];
imagelcon[1]= imagelcon[2];
imagelcon[0]= imageMcon;
imageMcon=null;
}else if ((JButton)e.getSource()==button[2])
{
for (int i=2; i>=0;i--);
imageMcon= imagelcon[0];
imagelcon[0]= imagelcon[1];
imagelcon[1]= imagelcon[2];
imagelcon[0]= imageMcon;
imageMcon=null;
}
}
JButton button[];
ImageIcon imagelcon[];
}