[求助]创建的类为什么也有错?
import java.awt.*;import javax.swing.*;
import java.awt.event.*;
public class c11_6 extends JApplet
{
int x,y;
JLabel lb1=new JLabel("x"),lb2=new JLabel("y"),lb3=new JLabel("");
JTextField tf1=new JTextField(5),tf2=new JTextField(5);
Container cp=getContentPane();
FlowLayout flow=new FlowLayout(FlowLayout.CENTER,5,5);
public void init()
{
cp.setLayout(flow);
cp.add(lb1);
cp.add(tf1);
cp.add(lb2);
cp.add(tf2);
cp.add(lb3);
addMouseListener(new mouseListener());
addMouseMotionListener(new koLis());
}
class mouseListener implements MouseListener//这里创建的类为什么会有错呢?
{
public void mouseClicked(MouseEvent e)
{lb3.setText("点击鼠标");}
public void mousePressed(MouseEvent e)
{lb3.setText("鼠标按钮按下");}
public void mouseEntered(MouseEvent e)
{lb3.setText("鼠标进入窗口");}
}
class koLis implements MouseMotionListener
{
public void mouseMoved(MouseEvent e)
{
x=e.getX();//返回发生鼠标事件的X坐标
y=e.getY();
tf1.setText(String.valueOf(x));//返回当前字符串
tf2.setText(String.valueOf(y));
}
public void mouseDragged(MouseEvent e)
{lb3.setText("拖动鼠标");}
}
}