在Java中如何判断小鼠鼠被按下的是左键还是右键
1个回答
展开全部
public void mouseClicked(MouseEvent e)
{
String outStr = "";
if(e.getButton() == e.BUTTON1)
{
outStr = "左键";
}
else if(e.getButton() == e.BUTTON3)
{
outStr = "右键";
}
else
{
outStr = "中键";
}
if(e.getClickCount() == 2)
{
outStr = outStr + "双击";
}
else
{
outStr = outStr + "点击";
}
System.out.println(outStr);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询