本帖最后由 CHNRosin 于 2011-08-26 17:41:13 编辑

解决方案 »

  1.   

    使用 javax.swing.Timer.
    ImageIcon[] icons = 
    Random random = new Random();new Timer(1000,new ActionListener(){
        public void actionPerformed(ActionEvent e){
            label.setIcon(icons[random.nextInt(icons.length)]);
        }
    });
      

  2.   

    web一样效果的图片切换 用swing 你看看这个 是不是你想要的http://www.blogjava.net/chensiyu04/articles/356961.html
      

  3.   

    1楼的帅哥,根据你那个方法我得出了以下代码,杯具的是我想让他按顺序切换图片,不知道循环怎么加,加在哪里。final ImageIcon[] icons = new ImageIcon[5];
    icons[0] = new ImageIcon(
    this.getClass().getResource("/com/panSky/picture/标签.jpg"));
    icons[1] = new ImageIcon(
    this.getClass().getResource("/com/panSky/picture/经济舱.jpg"));
    icons[2] = new ImageIcon(
    this.getClass().getResource("/com/panSky/picture/特级经济舱.jpg"));
    icons[3] = new ImageIcon(
    this.getClass().getResource("/com/panSky/picture/豪华商务舱.jpg"));
    icons[4] = new ImageIcon(
    this.getClass().getResource("/com/panSky/picture/标签2.JPG"));
    // int delay = 1000;
    // ActionListener ChangeImg = new ActionListener() {
    //
    // public void actionPerformed(ActionEvent arg0) {
    // label_held.setIcon(icons[i]);
    // }
    //
    // };
    // new Timer(delay, ChangeImg).start();
    final Random random = new Random();
    new Timer(1000, new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {
    label_held.setIcon(icons[random.nextInt(icons.length)]);
    }
    }).start();

    }
      

  4.   

    private int i = 0;icons[(i++) % icons.length()]