/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package javaapplication1; import com.samodelkin.*; import java.awt.*; import java.awt.geom.AffineTransform; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.*; /** * * @author Сергей */ public class MyCanvas extends JPanel implements Runnable{ private BaseSprite s; public MyCanvas() { this.setSize(600,600); try{ s=new BaseSprite(ImageIO.read(getClass().getResourceAsStream("images/image.png"))); }catch(Exception e){} s.setPosition(100, 100); new Thread(this).start(); } public void paintComponent(Graphics g){ super.paintComponent(g); g.setColor(Color.red); g.drawLine(0, 0, 100, 100); s.paint(g); } public void run(){ while(true){ this.repaint(); try{Thread.sleep(100);}catch(Exception e){} } } }