java高手请进,画图程序的监听器不起作用,鼠标画图无响应,鼠标画不上去是什么问题?

//这是我的两个监听器:classMouseAextendsMouseAdapter{publicvoidmouseEntered(MouseEventme){//TOD... //这是我的两个监听器:
class MouseA extends MouseAdapter {
public void mouseEntered(MouseEvent me) {
// TODO 鼠标进入
System.out.println("鼠标进入在:[" + me.getX() + " ," + me.getY() + "]");
}
public void mouseExited(MouseEvent me) {
System.out.println("鼠标退出在:[" + me.getX() + " ," + me.getY() + "]");
}
@Override
public void mousePressed(MouseEvent me) {
System.out.println("鼠标按下在:[" + me.getX() + " ," + me.getY() + "]");// 设置状态栏提示
itemList[curr].x1 = itemList[curr].x2 = me.getX();
itemList[curr].y1 = itemList[curr].y2 = me.getY();
curr++;
createNew();// 创建新的图形的基本单元对
repaint();
}
}
public void mouseReleased(MouseEvent me) {
// TODO 鼠标松开
System.out.println("鼠标松开在:[" + me.getX() + " ," + me.getY() + "]");
itemList[curr].x1 = itemList[curr].x2 = me.getX();
itemList[curr].y1 = itemList[curr].y2 = me.getY();
repaint();
curr++;
createNew();// 创建新的图形的基本单元对象
}
class MouseB extends MouseMotionAdapter {
public void mouseDragged(MouseEvent e)// 鼠标的拖动
{
System.out.println("鼠标拖动在:[" + e.getX() + " ," + e.getY() + "]");
itemList[curr - 1].x1 = itemList[curr].x2 = itemList[curr].x1 = e
.getX();
itemList[curr - 1].y1 = itemList[curr].y2 = itemList[curr].y1 = e
.getY();
curr++;
createNew();// 创建新的图形的基本单元对象
repaint();
}
public void mouseMoved(MouseEvent me)// 鼠标的移动
{
System.out.println("鼠标移动在:[" + me.getX() + " ," + me.getY() + "]");
}

}}
另附Drawing类:
public class Drawing implements Serializable {
int x1, y1, x2, y2;// 当前坐标
int R, G, B;// 当前色彩
Color c;
float f;// 当前笔触粗细
public void draw(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.drawLine(x1, y1, x2, y2);
}
}
class pencil extends Drawing {
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.drawLine(x1, y1, x2, y2);
}
}只要随笔画一个功能,就是用鼠标画图。请问监听器为什么没有响应?
展开
 我来答
匿名用户
2013-05-06
展开全部
这得看
itemList[curr - 1].x1 = itemList[curr].x2 = itemList[curr].x1 = e
.getX();
itemList[curr - 1].y1 = itemList[curr].y2 = itemList[curr].y1 = e
.getY();
curr++;
createNew();// 创建新的图形的基本单元对象
repaint();
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式