public class MyLabel extends JLabel
{
//双缓冲技术
private Image off_screen_buf;
private Graphics off_screen_gc;
public void paint(Graphics g)
{
if(Myjxta.image!=null)
{
this.setPreferredSize(new Dimension(Myjxta.image.getWidth(),Myjxta.image.getHeight()));
g.drawImage(Myjxta.image, 0, 0, this);
}
try
{
Thread.sleep(200);
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void update(Graphics g)
{
if (Myjxta.image != null)
{off_screen_buf =this.createImage(this.getWidth(),this.getHeight());
off_screen_gc = off_screen_buf.getGraphics();
paint(off_screen_gc);
off_screen_gc.dispose();
g.drawImage(off_screen_buf,0,0,null);
this.repaint() ;
}
}
}
