Topic: 鼠标事件问题? |
Print this page |
1.鼠标事件问题? | Copy to clipboard |
Posted by: jsxww2002 Posted on: 2005-05-22 10:19 请问在JAVA中怎样区分鼠标的左键和右键事件(点左键或右键)? 我有mousePressed 发现左右是一样的效果。应该用什么啊? |
2.Re:鼠标事件问题? [Re: jsxww2002] | Copy to clipboard |
Posted by: mesocool Posted on: 2005-05-22 10:42 MouseListener,public void mouseClicked(MouseEvent e) method e.getButton()来判断触发的是哪个按键 |
3.Re:鼠标事件问题? [Re: jsxww2002] | Copy to clipboard |
Posted by: jsxww2002 Posted on: 2005-05-22 11:49 能稍微具体点吗?我是个初学者!e.getButton()得到什么为左键,什么是右键 |
4.Re:鼠标事件问题? [Re: jsxww2002] | Copy to clipboard |
Posted by: mesocool Posted on: 2005-05-22 12:50 public void mouseClicked(MouseEvent? e) { if ((e.getModifiers() & InputEvent.BUTTON1?_MASK) != 0) saySomething( "button1 pressed", e); if ((e.getModifiers() & InputEvent.BUTTON2?_MASK) != 0) saySomething( "button2 pressed",e ); if ((e.getModifiers() & InputEvent.BUTTON3?_MASK) != 0) saySomething( "button3 pressed",e ); if ((e.getModifiers() & InputEvent?.ALT_MASK) != 0) saySomething( "alt pressed" ,e); if ((e.getModifiers() & InputEvent?.META_MASK) != 0) saySomething( "meta pressed",e ); } |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |