graphics画线起点中出现问题

packageGraphics;importjava.awt.*;importjava.awt.event.*;publicclassDrawLine{Framef=ne... package Graphics;

import java.awt.*;
import java.awt.event.*;

public class DrawLine {
Frame f = new Frame("画板");
public static void main(String[] args)
{
new DrawLine().init();
}
public void init()
{
f.setSize(300,300);
f.setVisible(true);
f.addMouseListener(new MouseAdapter()
{
int orgX;
int orgY;
public void monsePressed(MouseEvent e)
{
orgX = e.getX();
orgY = e.getY();
}
public void mouseReleased(MouseEvent e)
{
f.getGraphics().setColor(Color.BLUE);
f.getGraphics().drawLine(orgX, orgY, e.getX(), e.getY());
}
});
f.addWindowListener(new MyWindowListener());
}
}

class MyWindowListener implements WindowListener//监听窗口,使用关闭
{
public void windowClosing(WindowEvent e)
{
e.getWindow().setVisible(false);
((Window)e.getComponent()).dispose();
System.exit(0);
}

public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
//public void windowCloing(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){}

}
程序能正确运行,但在画线的时候起点和颜色都不能变化.请问是什么原因啊
看来很不认真啊,,把u写成n了还一直没发现.看来路还要走很长
展开
 我来答
亓昂熙5V
2008-08-19 · TA获得超过231个赞
知道小有建树答主
回答量:335
采纳率:0%
帮助的人:0
展开全部
错就错在
public void monsePressed(MouseEvent e)
{
orgX = e.getX();
orgY = e.getY();
}

你的这个方法名字写错了,系统没调用

mousePressed
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式