JAVA鼠标点击,键盘移动
我想选择 JFrame 内的一个对象并使用键盘箭头键移动它。我做了键盘的事情,每当我按下箭头键时,它就会相应地按照方向移动。我想要的是移动多个物体。我尝试放置多个对象,但它们确实同时移动了 xD
tldr;有没有一种方法可以使用鼠标单击一个对象并使用键盘箭头键控制它?
I wanted to select an object inside the JFrame and move it with the keyboard arrow keys. I did the keyboard thing, whenever I pressed the arrow keys it moves accordingly to the direction. What I want is to move multiple objects. I tried to put an multiple objects and they did moved at the same time xD
tldr; is there a way where you can click on just one object using the mouse and control it with keyboard arrow keys?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管问题不够清楚,移动单个或多个对象不是问题。您需要为您想要监听的对象使用KeyEvent Listener,并根据KeyEvent移动组件。
这里有一些参考: http://download.oracle.com/javase/tutorial /uiswing/events/keylistener.html
Eventhough question not clear enough, moving single or multiple objects is not a problem. You need to use KeyEvent Listener for the object you want to listen and move the components based on KeyEvent.
Here some reference: http://download.oracle.com/javase/tutorial/uiswing/events/keylistener.html