import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.Timer;
public class testGUI implements ActionListener {
           
            CardLayout card=new CardLayout();
            
            JPanel jp=new JPanel();
            JPanel jp1=new JPanel();
        public void actionPerformed(ActionEvent e){
            Timer time =new Timer(100,this);
            String command =e.getActionCommand();
            System.out.println(command);            if("第一张".equals(command)){
            card.first(jp1);
            }else if("下一张".equals(command)){
            card.next(jp1);
            }else if("上一张".equals(command)){
            card.previous(jp1);
            }
            else if("最后一张".equals(command)){
            card.last(jp1);
            }
            else if("开始".equals(command)){
             time.start();
             }
            else if("停止".equals(command)){
             time.stop();
             }else{
              card.next(jp1);
             }
            }
             public  testGUI(){ init();}
             public void  init(){
                 JFrame jf= new JFrame("");
    jf.setLocation(300,200);
    jf.setSize(500,600);
   
         String[] bt={"第一张","下一张","下一张","最后一张","开始","停止"};
    String[] jpg={"1.jpg","2.jpg","3.jpg","4.jpg"};
    
    for(int i=0;i<bt.length;i++){
    JButton jb=new JButton(bt[i]);
                   jb.addActionListener(this);
     jp.add(jb);
    }
            
            jf.add(jp,BorderLayout.NORTH);
    for(int j=0;j<jpg.length;j++){
     Icon image=new ImageIcon(".\\pic\\"+jpg[j]);
     JLabel  jl=new JLabel(image);
     jp1.add(jl);
    }
    jp1.setLayout(card);
    jf.add(jp1);
              jf.setResizable(false);
              jf.setVisible(true);
              jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
        public static void main(String[] args){
                new testGUI();
}
}点停止按钮不能停止 还在播放 why?