import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//definition of JPanel
class mypanel5 extends JPanel
implememts MouseMotionListener
{
public mypanel5()
{
addMouseListener(new MouseAdapter()
{ public void mouseClicked(MouseEvent evt)
{
int i=evt.getClickCount();
if(i==1)
System.out.println("the clicknumber is one.");
if(i==2)
System.out.println("the clicknumber is two.");
int x=evt.getX();
int y=evt.getY();
System.out.println("the position is ("+x+","+y+").");
}
public void mousePressed(MouseEvent evt)
{
System.out.println("the mouse has pressed.");
}
public void mouseReleased(MouseEvent evt)
{
System.out.println("the mouse has released.");
}
});
add MouseMotionListener(this);
}
// to implement the mousemotionlistener
public void mouseDragged(MouseEvent evt)
{
System.out.println("the mouse is dragging.");
}
public void mouseMoved(MouseEvent evt)
{
System.out.println("the mouse is moving .");
}
public void paint(Graphics g)
{
setBackground(Color.yellow);
}
}
上面这个程序同步过编译,说是第六行和第十五行缺少括号,请大家看看啊