日期:2014-05-20 浏览次数:20656 次
import javax.swing.JFrame;
import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
public class Fish extends JFrame{
private static Toolkit tk = Toolkit.getDefaultToolkit();
private static Image img;
static{img = tk.getImage(Fish.class.getClassLoader().getResource("images/1.jpg"));}
public Fish() {
this.setSize(440,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(new CanvasPanel());
}
public void draw(Graphics g) {
g.drawImage(img,0,0,this);
}
}