为什么this.addMouseListener(new MuoseAdapter()这里会报错啊?

我编写了如下代码,如下
package myprojects.drawline;
import java.awt.*;
import java.awt.event.*;
class drawline extends Frame {
public drawline (){
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
this.addMouseListener(new MuoseAdapter()
{
int orgX;
int orgY;
public void mousePressed(MouseEvent e)
{
orgX = e.getX();
orgY = e.getY();
}
public void mouseReleased(MouseEvent e)
{
Graphics g = getGraphics();
g.setColor(Color.RED);
g.setFont(new Font(null,Font.ITALIC|Font.BOLD,30));
g.drawString(orgX+","+orgY ,orgX,orgY);
g.drawString(e.getX()+","+e.getY() ,e.getX(),e.getY());
g.drawLine(orgX,orgY,e.getX(),e.getY());
}
}
);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Starting drawline");
drawline mainFrame = new drawline();
mainFrame.setSize(400,400);
mainFrame.setTitle("画线测试");
mainFrame.setVisible(true);
}
}

森栏
浏览 160回答 2
2回答

噜噜哒

MuoseAdapter这个写错了MouseAdapter

达令说

把this改为super把 是继承父类的
打开App,查看更多内容
随时随地看视频慕课网APP