| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 503 人关注过本帖
标题:鼠标监听求助
只看楼主 加入收藏
mashunty
Rank: 1
等 级:新手上路
帖 子:4
专家分:9
注 册:2013-9-11
收藏
 问题点数:0 回复次数:0 
鼠标监听求助
在做游戏的时候我用鼠标监听方法来去读取地图点击事件,但是无法和自己做的地图同步加载不进地图,自动生成的监听方法不能通过函数直接调用ReadingMap 是我的地图的类,
例如:public void mouseDragged(MouseEvent e) {
        // TODO Auto-generated method stub
        String string = "鼠标拖动到位置:(" + e.getX() + "," + e.getY() +")";
    }
无法通过mouseDragged来去调用此函数;
public class Mouse implements MouseMotionListener,MouseListener {
     
    ReadingMap frame;        
    public Mouse(){                  
        frame.addMouseListener(this);  
        frame.addMouseMotionListener(this);  
        frame.addWindowListener(new WindowAdapter() {  
            @Override  
            public void windowClosing(WindowEvent e) {  
                // TODO Auto-generated method stub  
                System.exit(0);  
            }  
        });   
        frame.setVisible(true);  
    }
   
    public void mouseClicked(MouseEvent e ){
        // TODO Auto-generated method stub
         System.out.print("鼠标点击----" + "\t");  
            if (e.getClickCount()==1) {  
                System.out.println("单击!");  
            } else if (e.getClickCount()==2) {  
                System.out.println("双击!");  
            } else if (e.getClickCount()==3) {  
                System.out.println("三连击!!");  
            }  
    }

    @Override
    public void mouseEntered(MouseEvent arg0) {
        // TODO Auto-generated method stub
        System.out.println("鼠标");
    }

    @Override
    public void mouseExited(MouseEvent arg0) {
        // TODO Auto-generated method stub
        System.out.println("鼠标单击");
    }

    @Override
    public void mousePressed(MouseEvent arg0) {
        // TODO Auto-generated method stub
        System.out.println("鼠标按下");
    }

    @Override
    public void mouseReleased(MouseEvent arg0) {
        // TODO Auto-generated method stub
        System.out.println("鼠标放开");
    }

    @Override
    public void mouseDragged(MouseEvent e) {
        // TODO Auto-generated method stub
        String string = "鼠标拖动到位置:(" + e.getX() + "," + e.getY() +")";
    }

    @Override
    public void mouseMoved(MouseEvent arg0) {
        // TODO Auto-generated method stub
        System.out.println("鼠标移动");
    }
搜索更多相关主题的帖子: public frame method 游戏 
2013-09-11 23:13
快速回复:鼠标监听求助
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016323 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved