图片加载!谁能帮忙把每条语句注释一下!

2016-07-14

package test;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Toolkit;
import javax.swing.JFrame;
import java.awt.MediaTracker;
public class StartFrame extends JFrame implements Runnable{
 
 Image imageWithFont;
 Image imageWithoutFont;
 MediaTracker tracker;
 Image memoryImage;
 Graphics memoryGraphics;
 boolean isRun=true;
 Image titleImage;
 int changeImage =1;
 Thread thread;
 
 public StartFrame()
 {
  imageWithFont =
   Toolkit.getDefaultToolkit().getImage(StartFrame.class.getResource

("../image/title1.jpg"));
  imageWithoutFont =
   Toolkit.getDefaultToolkit().getImage(StartFrame.class.getResource

("../image/title2.jpg"));
  
  tracker = new MediaTracker(this);
  tracker.addImage(imageWithFont, 0);
  tracker.addImage(imageWithoutFont, 0);
  try {
   tracker.waitForID(0);
  } catch (InterruptedException e1) {
   e1.printStackTrace();
  }
  
  
  
  this.setSize(imageWithFont.getWidth(this), imageWithFont.getHeight(this));
  this.setTitle("片头动画");
  this.setResizable(false);
  this.setLocationRelativeTo(null);
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  this.setVisible(true);
  
  memoryImage = this.createImage(this.getWidth(), this.getHeight());
  memoryGraphics = memoryImage.getGraphics();
  
  thread = new Thread(this);
  thread.start();
  
  this.addWindowListener(new WindowAdapter(){
   public void windowClosing(WindowEvent e)
   {
    System.exit(0);
   }
  });
 }
 
 public void update(Graphics g)
 {
  memoryGraphics.drawImage(titleImage, 0, 0, this);
  g.drawImage(memoryImage, 0, 0, this);
 }

 /**
  * @param args
  */
 public static void main(String[] args) {
  new StartFrame();

 }

 public void run() {
  while(isRun)
  {
   try {
    Thread.sleep(100);
   } catch (InterruptedException e) {
    
    e.printStackTrace();
   }
   if(this.changeImage==2)
   {
    this.titleImage = this.imageWithFont;
    changeImage=1;
   }
   else
   {
    this.titleImage = this.imageWithoutFont;
    changeImage++;
   }
   this.repaint();
  }
  
 }

}