import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class Test4_3 extends JFrame{ PaoPao mp2;
public static void main(String[] args) {
// TODO Auto-generated method stub
Test4_3 test4_3=new Test4_3();
}
public Test4_3()
{
mp2=new PaoPao();
this.add(mp2);

this.setSize(800,600);

this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);

Thread t=new Thread(mp2);
t.start();
}}class PaoPao extends JPanel implements Runnable
{
int x=100;
int y=100;
int width=800;
int height=600;
//定义泡泡的方向
int direction=1;

//定义泡泡速度
int speed=5;
//逆时针走

private Image iBuffer;  
private Graphics gBuffer; public void running()
         
         {
switch (direction)
{
//右下方向 ↘
case 1:
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
x+=speed;
y+=speed;
if(y>=height)
{
this.direction=2;
}else if(x>=width)
{
this.direction=-2;
}
break;
//右上 ↗
case 2:
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
x+=speed;
y-=speed;
if(x>=width)
{
direction=-1;
}else if(y<=0)
{
direction=1;
}
break;
//左上 ↖
case -1:
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
x-=speed;
y-=speed;
if(y<=0)
{
direction=-2;
}else if(x<=0)
{
direction=2;
}
break;
//坐下 ↙
case -2:
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
x-=speed;
y+=speed;
if(x<=0)
{
direction=1;
}else if(y>=height)
{
direction=-1;
}
break;
}
this.repaint();
}
public void paint(Graphics scr)  { 
iBuffer=Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/paopao.png"));
scr.drawImage(iBuffer,x,y,134,134,this);
}   
public void update(Graphics scr) 

    if(iBuffer==null) 
    { 
       iBuffer=createImage(this.getSize().width,this.getSize().height); 
       gBuffer=iBuffer.getGraphics(); 
    } 
       gBuffer.setColor(getBackground()); 
       gBuffer.fillRect(0,0,this.getSize().width,this.getSize().height); 
       paint(gBuffer); 
       scr.drawImage(iBuffer,0,0,this); 
}  public void run() {
// TODO Auto-generated method stub
while(true)
{
this.running();
}

}

}
最后都粘一块了,但是如果把那张图片换成自己画的,就不会粘一块,这是为什么?具体怎么解决??