import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.applet.Applet.*;
public class m1 extends JApplet
{
JButton b1=new JButton("1");
int m_x,m_y;
public void init()
{setLayout(null);
b1.addMouseMotionListener(new MouseMotionAdapter()
{
public void mouseDragged(MouseEvent e)
{
m_x=e.getX();
m_y=e.getY();
b1.setLocation(m_x,m_y);
}
});
b1.setSize(50,50);
add(b1);
}
}
我想用以上的程序实现鼠标拖动按纽的效果!.
问题:在拖动是出现了象残影那样的现象!
请帮我!谢!
----------------解决方案--------------------------------------------------------
public void mouseDragged(MouseEvent e)
{
this.remove(b1);
m_x=e.getX();
m_y=e.getY();
b1.setLocation(m_x,m_y);
b1.setsize(50,50);
this.add(b1);
this.updateUI();
}
});
试试行不行
----------------解决方案--------------------------------------------------------
貌似不行啊!!出现点错误!
(编不过)this.updateUI();什么意思??请说清楚点!
----------------解决方案--------------------------------------------------------