home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161b.iso / handson / archive / Issue159 / files / java / ex1 / Example1.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-10-03  |  2.3 KB  |  62 lines

  1. import java.awt.BorderLayout;
  2. import java.awt.Color;
  3. import java.awt.Frame;
  4. import java.awt.Graphics;
  5. import java.awt.Image;
  6. import java.io.FileOutputStream;
  7. import java.io.IOException;
  8. import java.io.PrintStream;
  9.  
  10. public class Example1 {
  11.    private Frame frm;
  12.    private Animator animator;
  13.    // $FF: renamed from: g java.awt.Graphics
  14.    private Graphics field_0;
  15.    private static final int WIDTH = 200;
  16.    private static final int HEIGHT = 200;
  17.    private static final int BORDER = 20;
  18.  
  19.    public static void main(String[] var0) {
  20.       Example1 var1 = new Example1();
  21.       var1.init();
  22.    }
  23.  
  24.    public void init() {
  25.       this.frm = new Frame();
  26.       this.frm.setLayout(new BorderLayout());
  27.       this.frm.setTitle("Processing...");
  28.       this.frm.setSize(200, 220);
  29.       this.frm.addWindowListener(new Example1$1(this));
  30.       this.frm.show();
  31.    }
  32.  
  33.    private void createAnim() {
  34.       Image var1 = this.frm.createImage(200, 200);
  35.       Graphics var2 = var1.getGraphics();
  36.       this.animator = Animator.getInstance("GIF", 200, 200);
  37.       this.animator.setFPS(40);
  38.       this.field_0 = this.frm.getGraphics();
  39.  
  40.       for(int var3 = 0; var3 < 100; var3 += 3) {
  41.          var2.setColor(Color.white);
  42.          var2.fillRect(0, 0, 200, 200);
  43.          var2.setColor(new Color(2 * var3, 0, 255 - 2 * var3));
  44.          var2.fillRect(var3, var3, 100, 100);
  45.          this.animator.addImage(var1, this.frm);
  46.          this.field_0.drawImage(var1, 0, 20, this.frm);
  47.       }
  48.  
  49.       try {
  50.          this.animator.getAnimation().serializeTo(new PrintStream(new FileOutputStream("ex1.gif")));
  51.       } catch (IOException var4) {
  52.       }
  53.  
  54.       System.exit(0);
  55.    }
  56.  
  57.    // $FF: synthetic method
  58.    static void access$0(Example1 var0) {
  59.       var0.createAnim();
  60.    }
  61. }
  62.