JSlider 按键绑定
所以我对 JSlider 垂直滑块的默认键绑定有点困惑。
- Home:转到底部(为什么不是顶部?)
- End:转到顶部(为什么不是底部?)
- PageUp/PageDown:方向很好,但向上上升了一些 K,我无法控制
- 向上/向下箭头键:方向很好,但增加了 1,并且我有一个高粒度滑块(0 到 65535),我希望对其进行更直观的控制。
有没有办法自定义这种行为?
So I'm a bit nonplussed at the JSlider default key bindings for vertical sliders.
- Home: goes to the bottom (why not the top?)
- End: goes to the top (why not the bottom?)
- PageUp/PageDown: direction good, but goes up by some amount K which I can't control
- up/down arrow keys: direction good, but goes up by 1, and I have a high-granularity slider (0 to 65535) which I would like to have a little more intuitive control over.
Is there a way to customize this behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过
getInputMap
和getActionMap
方法访问键绑定。例如,要切换 home/end 键绑定(使 Home 转到顶部,end 转到底部):
这里有有关键绑定的教程。
You can access the keybindings via the
getInputMap
andgetActionMap
methods.For example, to switch the home/end key bindings (make Home go to the top, and end go to the bottom):
Here's a tutorial on key bindings.
对于菜单没有直接的方法。但您可能可以使用操作来达到您的目的: http:// java.sun.com/docs/books/tutorial/uiswing/misc/action.html
There isn't a straightforward way as for menus. But you can probably use actions for your purpose: http://java.sun.com/docs/books/tutorial/uiswing/misc/action.html