说我小程序未初始化,怎么回事,程序如下:
importjava.awt.*;importjava.applet.*;importjava.awt.event.*;publicclassMouseextendsAp...
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Mouse extends Applet implements MouseListener{
private int mouseX;
private int mouseY;
public void init(){
addMouseListener(this);
}
public void mousePressd(MouseEvent m){
mouseX=m.getX();
mouseY=m.getY();
repaint();
}
public void paint(Graphics g){
g.setColor(Color.blue);
g.drawLine(0,mouseY,200,mouseY);
g.drawLine(mouseX,0,mouseX,100);
}
public void mouseClicked(MouseEvent m){}
public void mouseEntered(MouseEvent m){}
public void mouseExited(MouseEvent m){}
public void mouseReleased(MouseEvent m){}
} 展开
import java.applet.*;
import java.awt.event.*;
public class Mouse extends Applet implements MouseListener{
private int mouseX;
private int mouseY;
public void init(){
addMouseListener(this);
}
public void mousePressd(MouseEvent m){
mouseX=m.getX();
mouseY=m.getY();
repaint();
}
public void paint(Graphics g){
g.setColor(Color.blue);
g.drawLine(0,mouseY,200,mouseY);
g.drawLine(mouseX,0,mouseX,100);
}
public void mouseClicked(MouseEvent m){}
public void mouseEntered(MouseEvent m){}
public void mouseExited(MouseEvent m){}
public void mouseReleased(MouseEvent m){}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询