display image after after on the panel with a time gap

前端 未结 2 758
礼貌的吻别
礼貌的吻别 2021-01-26 08:42
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.*;
import java.io.*;

import javax.swing.ImageIcon;
imp         


        
2条回答
  •  无人及你
    2021-01-26 09:26

    You can create a TimerTask

    class VideoTask extends TimerTask {
       private Frame frame;
       private int frameId;
       public void run() {
         frame.drawImage(....);
         frameId++;
       }
    }
    

    And in the action listener for the button - schedule the task:

    VideoTask videoTask = new VideoTask(frame);
    videoTask.schedule(..);
    

提交回复
热议问题